본문 바로가기

Windows Programming/Windows API

(9)
Local Host PC IP 주소 가져오기 - 2 #ifndef UNICODE #define UNICODE #endif #define WIN32_LEAN_AND_MEAN #include #include #include // Link with ws2_32.lib #pragma comment(lib, "Ws2_32.lib") int __cdecl wmain(int argc, wchar_t **argv) { WSADATA wsaData; int iResult = 0; INT iRetval = 0; DWORD dwRetval = 0; int i = 1; ADDRINFOW *result = NULL; ADDRINFOW *ptr = NULL; ADDRINFOW hints; LPSOCKADDR sockaddr_ip; wchar_t strIPBuffer[46] = {..
Local Host PC IP 주소 가져오기 (gethostbyname API) gethostbyname() API https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-gethostbyname gethostbyname function (winsock2.h) - Win32 apps The gethostbyname function retrieves host information corresponding to a host name from a host database. docs.microsoft.com #define _WINSOCK_DEPRECATED_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS // #include #include #include #include // #prag..
윈도우 프로세스 목록 가져오기 CreateToolhelp32Snapshot API MSDN 주소 - https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot CreateToolhelp32Snapshot function (tlhelp32.h) - Win32 apps Takes a snapshot of the specified processes, as well as the heaps, modules, and threads used by these processes. docs.microsoft.com Process32First API MSDN 주소 - https://docs.microsoft.com/en-us/windows/..
윈도우 드라이브 정보 가져오기 (QueryDosDevice API) QueryDosDevice API MSDN 주소 - https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-querydosdevicew QueryDosDeviceW function (fileapi.h) - Win32 apps Retrieves information about MS-DOS device names. docs.microsoft.com #include #include #include #define MAX_SIZE 2048 int main(void) { CHAR szDriveBuf[MAX_SIZE] = { 0, }; CHAR szFileSystem[MAX_SIZE] = { 0, }; INT nLen = GetLogicalDriv..
윈도우 전체 사용자 목록 및 전체 사용자 SID 얻기 GetComputerName API MSDN - https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcomputernamew GetComputerNameW function (winbase.h) - Win32 apps Retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry. docs.microsoft.com LookupAccountName API MSDN 주소 - https://docs.microsoft.com/en-us/windows/win..
윈도우 시스템 이름 얻어오기 (GetHostName API) GetHostName API MSDN 주소 - https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcomputernamea GetComputerNameA function (winbase.h) - Win32 apps Retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry. docs.microsoft.com #include #include #include #define MAX_LEN 1024 int main(void) { DWORD dwSize..
윈도우 현재 사용자 이름 얻어오기 (GetUserName API) GetUserName API MSDN 주소 - https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getusernamea GetUserNameA function (winbase.h) - Win32 apps Retrieves the name of the user associated with the current thread. docs.microsoft.com #include #include #include #define MAX_LEN 1024 int main(void) { DWORD dwSize = MAX_LEN; CHAR strUserName[MAX_LEN] = { 0, }; INT nError = GetUserName(strUse..
윈도우 드라이브 목록 가져오기 (GetLogicalDriveStrings API) GetLogicalDriveStrings API MSDN - https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getlogicaldrivestringsw GetLogicalDriveStringsW function (fileapi.h) - Win32 apps Fills a buffer with strings that specify valid drives in the system. docs.microsoft.com #include #include #include #define DRIVE_BUFFER 1024 int main(void) { CHAR szDriveBuf[DRIVE_BUFFER] = { 0, }; INT nCount = G..