#include "stdafx.h" int main(int argc, char* argv[]) { printf( "%s\n", argv[0] ); return 0; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MessageBox( NULL, GetCommandLine(), "CommandLine", MB_OK );
#include "tlhelp32.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { HANDLE hSnapshot; PROCESSENTRY32 pe; DWORD ProcessId; ProcessId = GetCurrentProcessId(); hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS , 0); if (hSnapshot) { pe.dwSize = sizeof(PROCESSENTRY32); if ( Process32First(hSnapshot, &pe) ) { while( 1 ) { if (pe.th32ProcessID == ProcessId) { MessageBox( NULL, pe.szExeFile, "実行ファイル", MB_OK ); break; } if ( !Process32Next(hSnapshot, &pe) ) { break; } } } CloseHandle(hSnapshot); }
GetWindowThreadProcessId( hWnd, &ProcessId );