본문 바로가기
728x90
반응형

프로그래밍/Windows26

Windows Socket C/C++ example 출처 : https://msdn.microsoft.com/en-us/library/windows/desktop/ms737591(v=vs.85).aspxhttps://msdn.microsoft.com/en-us/library/windows/desktop/ms737593(v=vs.85).aspx client.c1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111.. 2017. 10. 31.
Windows Socket Client 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#include #include #include #pragma comment(lib, "ws2_32.lib")void ErrorHandling(char* message); int main(int argc, char* argv[]){ WSADATA wsaData; SOCKET hSocket; SOCKADDR_IN servAddr; char IPaddr[52]; int port; char msg[1024]; int len; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) ErrorHandling("WSAS.. 2016. 9. 4.
파일 속성 변경 - SetFileAttributes 함수 이름 그대로 파일의 속성을 세팅하는 함수. 1234BOOL WINAPI SetFileAttributes( _In_ LPCTSTR lpFileName, _In_ DWORD dwFileAttributes);cs 악성코드 분석하다가 알게 되었다. 전에 분석하던 악성코드는 악성코드가 하는 일들을 수행하고 자기 자신을 숨김 파일로 변경하였음. 속성에 대한 define 값은 MSDN을 참고. https://msdn.microsoft.com/ko-kr/library/windows/desktop/aa365535(v=vs.85).aspx 123456789101112#include#include#includeint main() { char buf[MAX_PATH]; GetModuleFileNameA(NULL, buf.. 2016. 1. 11.
버튼 클릭하면 이미지 나오게 하기 1234567891011121314151617LRESULT OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam){ switch (LOWORD(wParam)){ case 100: hdc = GetDC(hWnd); MemDC = CreateCompatibleDC(hdc); OldBitmap = (HBITMAP)SelectObject(MemDC, hBitmap[0]); BitBlt(hdc, 30, 30, 500, 500, MemDC, 0, 0, SRCCOPY); SelectObject(MemDC, OldBitmap); DeleteDC(MemDC); ReleaseDC(hWnd, hdc); break; case 101: break; } return 0;}Colored by C.. 2015. 7. 26.
아스키코드 -> 유니코드 문자열 변환 함수 1234567891011#include#include#include#includeint main(){ TCHAR str[50] = { 0, }; USES_CONVERSION; _tcscpy(str, A2T("test")); MessageBox(NULL, str, L"test", MB_OK);}Colored by Color Scriptercs A2T를 사용하는 함수마다 한 번씩 USES_CONVERSION; 을 써줘야 하나보다. 2015. 6. 3.
WinAPI 콤보박스 생성 / ComboBox 1 2 3 4 5 6 7 8 9 10 TCHAR *str[] = { L"AOA", L"Girl's Day", L"Apink" }; int i; hSelect = CreateWindow(L"combobox", NULL, WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, 310, 90, 155, 80, hWnd, (HMENU)CB_SELECT, g_hInst, NULL); for (i = 0; i 2015. 6. 1.
process list 출력 방법 1. NtQuerySystemInformation (windows 2000/NT 이상에서 가능)(출처: http://www.rohitab.com/discuss/topic/40504-using-ntquerysysteminformation-to-get-process-list/) 방법 2. CreateToolhelp32Snapshot 아.. 슈방 옛날에 구현해놨었는데 당시 무슨 패기였는지 삭제해버려서 다시 정리. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include #include #include #pragma comment(lib,"ntdll.lib") .. 2015. 5. 20.
how to create ListView on Visual C++ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 #include HWND hList; void MakeProcListView(HWND hWnd){ LVCOLUMN COL; LVITEM Li; hList = CreateWindow(WC_LISTVIEW, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL, 0, 0, 250, 200, hWnd, (HMENU)hProcList, g_hIns.. 2015. 5. 20.
사용자 입력 글자수 제한하기 SendMessage(hEdit[2], EM_LIMITTEXT, (WPARAM)1, 0); 윈도우 핸들, EM_LIMITTEXT, 제한할 글자 수, NULL 2014. 7. 4.
C++ WinForm Frame 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394#include //콜백함수LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);LRESULT OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);LRESULT OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);LRESULT OnPaint(HWND hWnd, WPARAM .. 2014. 7. 4.
쓰레드 동기화와 WAIT_ABANDONED Colored By Color Scripter™12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061#include#include#include#include LONG gTotalCount = 0;HANDLE hMutex; unsigned int WINAPI IncreaseCountOne(LPVOID lpParam){ WaitForSingleObject(hMutex, INFINITE); gTotalCount++; puts("1st thread"); //ReleaseMutex(hMutex); return 0;} unsigned int WINAPI Increas.. 2014. 6. 2.
GetExitCodeProcess Colored By Color Scripter™1234#includeint main(){ return 100;}a.cpp Colored By Color Scripter™1234567891011121314151617181920212223#include#includeint main(){ STARTUPINFO si = { 0, }; PROCESS_INFORMATION pi; DWORD ret = 0, test; TCHAR path[] = L"a.exe"; si.cb = sizeof(si); puts("#"); CreateProcess(NULL, path, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); CloseHandle(pi.hThread); //WaitForSingleOb.. 2014. 5. 25.
728x90
반응형