공부/API
시스템 디렉토리와 윈도우 디렉토리를 찾아보자.
잠수함토끼
2008. 8. 28. 21:57
아래의 두 함수 GetSystemDirectoryA와 GetWindowsDirectoryA를 사용해야 한다.
#include#include int main(void) { char szSystemDirectoryPath[100]={0,}; //시스템 버버를 저장하기 위한 버퍼 char szDllPath[100]={0,}; // Dll의 경로를 저장하기 위한 버퍼이다. char szWindowsDirectoryPath[100]={0,}; UINT ret = GetSystemDirectoryA(szSystemDirectoryPath,100); // Ansi기준으로 작성된 함수이다. unicode 방식으로 하면 잘못된 결과가 도출된다. sprintf(szDllPath, "%s\\WSock32.dll",szSystemDirectoryPath); //szDllPath를 완성하는 것이다. WSock32.dll을 로드하기 위한 작업으로 보인다. HINSTANCE hInst = LoadLibraryA(szDllPath); //Ansi기준으로 작성된 함수이다. unicode 방식으로 하려면 A대신 W로 붙이면된다. if(hInst == NULL) printf("error\n"); void *pFunc; pFunc = GetProcAddress(hInst,"recv"); printf("0x%x\n",pFunc); //윈도우의 디렉토리를 알고 싶을때 사용하면 된다. GetWindowsDirectoryA(szWindowsDirectoryPath,100); printf(szWindowsDirectoryPath); printf("\n"); return 0; }