winapi CreateFile 예제

#include #include int main() { // Open a handle to the file HANDLE hFile = CreateFile( L"C:\\NewFile.txt", // Filename GENERIC_WRITE, // Desired access FILE_SHARE_READ, // Share mode NULL, // Security attributes CREATE_NEW, // Creates a new file, only if it doesn't already exist FILE_ATTRIBUTE_NORMAL, // Flags and attributes NULL); // Template file handle if (hFile == INVALID_HANDLE_VALUE) { // ..

winapi 쓰레드 생성하기

#include DWORD WINAPI DoStuff(LPVOID lpParameter) { // The new thread will start here return 0; } int main() { // Create a new thread which will start at the DoStuff function HANDLE hThread = CreateThread( NULL, // Thread attributes 0, // Stack size (0 = use default) DoStuff, // Thread start address NULL, // Parameter to pass to the thread 0, // Creation flags NULL); // Thread id if (hThread == ..

winapi 프로세스 생성, exit code 확인하기

#include int main() { STARTUPINFOW si = { 0 }; si.cb = sizeof(si); PROCESS_INFORMATION pi = { 0 }; // Create the child process BOOL success = CreateProcessW( L"C:\\Windows\\system32\\notepad.exe", // Path to executable NULL, // Command line arguments NULL, // Process attributes NULL, // Thread attributes FALSE, // Inherit handles 0, // Creation flags NULL, // Environment NULL, // Working directo..