본문 바로가기

Windows Programming

(14)
C언어 Echo Client (1:1통신) #include #include #include #include #pragma comment(lib, "ws2_32")#define PORT 7777#define SERVER_IP "127.0.0.1"int main(void){ WSADATA wsaData = { 0, }; SOCKADDR_IN Addr = { 0, }; char strInput[MAX_PATH] = { 0, }, cRecvBuf[MAX_PATH] = { 0, }; SOCKET hSocket = NULL; int nErrorCode = 0; WSAStartup(MAKEWORD(2, 2), &wsaData); hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (hSocket..
C언어 Echo Server (1:1 통신) #define _CRT_SECURE_NO_WARNINGS#include #include #include #include #pragma comment(lib, "ws2_32")#define PORT 7777int main(void) { printf("Sever Working...\n\n"); WSADATA wsaData = { 0, }; SOCKADDR_IN listnAddr = { 0, }; SOCKADDR_IN ClntAddr = { 0, }; char buf[MAX_PATH] = { 0, }; SOCKET hListen = NULL; int iClntSize = 0, nErrorCode = 0; WSAStartup(MAKEWORD(2, 2), &wsaData); hListen = soc..
Windows Socket (Server) 윈도우 기반 서버 소켓 기본 코드 입니다. #include #include #include #include #pragma comment(lib, "ws2_32") #define PORT 8088 #define MAXSIZE 256 #define PACKET_SIZE 1024 int main(int argc, char *argv[]) { WSADATA wsaData; SOCKET hListen; int nRecv = 0; char buf[MAXSIZE] = { 0, }; WSAStartup(MAKEWORD(2, 2), &wsaData); hListen = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (hListen == -1) ErrorMsg("Socket Error!..
Windows Socket (Client) 윈도우 기반 클라이언트 소켓 기본 코드입니다. #include #include #include #include // #pragma comment(lib, "ws2_32") // #define PORT 5000 #define MAXSIZE 256 #define PACKET_SIZE 1024 #define SERVER_IP "127.0.0.1" // int main(void) { WSADATA wsaData; SOCKET hSocket; WSAStartup(MAKEWORD(2, 2), &wsaData); hSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (hSocket == -1) ErrorMsg("Socket() Error!"); SOCKADDR_IN Ad..
Visual Studio Device Driver 프로젝트 안 보일 경우 IDE 환경 : Visual Studio 2019 WDK Install URL https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk Download the Windows Driver Kit (WDK) - Windows drivers Download instructions for the latest released version of the Windows Driver Kit (WDK) docs.microsoft.com Visual Studio Installer에서 SDK, WDK 설치를 해도 간혹 사진과 같이 Driver 관련 프로젝트가 안나오는 경우가 있다. 이런 경우는 WDK.vsix 프로그램을 실행을 해주면 된다. 설치가..
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/..