diff --git a/cpp/list/main.cpp b/cpp/list/main.cpp index 3ef4755..95b444a 100644 --- a/cpp/list/main.cpp +++ b/cpp/list/main.cpp @@ -1,19 +1,62 @@ #include #include +#include +#include + +BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam); +BOOL GetProcessList(); using namespace std; -BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam); - -int main() { - EnumWindows(EnumProc, 0); - return 0; +int main(int argc, char **argv) { + if (argc == 2) { + if (*argv[1] == 'w') { + printf("handle\tpid\ttitle\n"); + EnumWindows(EnumProc, 0); + return 0; + } else if (*argv[1] == 'p') { + printf("pid\tname\n"); + GetProcessList(); + return 0; + } + } + return 1; } BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam) { - TCHAR title[500]; - ZeroMemory(title, sizeof(title)); - GetWindowText(hWnd, title, sizeof(title) / sizeof(title[0])); - printf("%d\n%s\n", hWnd, title); - return TRUE; + DWORD processId; + GetWindowThreadProcessId(hWnd, &processId); + TCHAR title[500]; + ZeroMemory(title, sizeof(title)); + GetWindowText(hWnd, title, sizeof(title) / sizeof(title[0])); + printf("%d\t%d\t%s\n", hWnd, processId, title); + return TRUE; +} + +BOOL GetProcessList() { + HANDLE hProcessSnap; + HANDLE hProcess; + PROCESSENTRY32 pe32; + + hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (hProcessSnap == INVALID_HANDLE_VALUE) { + return FALSE; + } + + pe32.dwSize = sizeof(PROCESSENTRY32); + if(!Process32First( hProcessSnap, &pe32 ) ) { + CloseHandle(hProcessSnap); + return FALSE; + } + + do { + hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID); + if( hProcess != NULL ) { + CloseHandle( hProcess ); + } + printf("%d\t%s\n", pe32.th32ProcessID, pe32.szExeFile); + } while (Process32Next(hProcessSnap, &pe32)); + + CloseHandle( hProcessSnap ); + return TRUE; } diff --git a/cpp/wiiscan/Release/DelcomDLL.dll b/cpp/wiiscan/Release/DelcomDLL.dll deleted file mode 100644 index ecfa470..0000000 Binary files a/cpp/wiiscan/Release/DelcomDLL.dll and /dev/null differ diff --git a/cpp/wiiscan/Release/USBm.dll b/cpp/wiiscan/Release/USBm.dll deleted file mode 100644 index 1460ff3..0000000 Binary files a/cpp/wiiscan/Release/USBm.dll and /dev/null differ diff --git a/cpp/wiiscan/Release/WiimoteLib.dll b/cpp/wiiscan/Release/WiimoteLib.dll deleted file mode 100644 index 4408358..0000000 Binary files a/cpp/wiiscan/Release/WiimoteLib.dll and /dev/null differ diff --git a/cpp/wiiscan/Release/wiimotelibpoll.exe b/cpp/wiiscan/Release/wiimotelibpoll.exe deleted file mode 100644 index 7e13580..0000000 Binary files a/cpp/wiiscan/Release/wiimotelibpoll.exe and /dev/null differ diff --git a/cpp/wiiscan/Release/wiiscan.exe b/cpp/wiiscan/Release/wiiscan.exe deleted file mode 100644 index 9e9e443..0000000 Binary files a/cpp/wiiscan/Release/wiiscan.exe and /dev/null differ diff --git a/cpp/wiiscan/Release/wiiscan.ini b/cpp/wiiscan/Release/wiiscan.ini deleted file mode 100644 index 8833211..0000000 --- a/cpp/wiiscan/Release/wiiscan.ini +++ /dev/null @@ -1,81 +0,0 @@ -% Configfile_begin - % config file for wiiscan - - % all usb device ids, not used yet in the scanning - all_usb_hubs="" - - % single power controlling usb hub, only nessesary when powerering over usb, for automatic resetting. If not used, put "" - % active_usb_hub="@PCI\VEN_8086&DEV_2934&SUBSYS_20F017AA&REV_03\3&B1BFB68&0&E8" - active_usb_hub="" - - % a list of allowed wiimotes in the form xx:xx:xx:xx:xx:xx, wildcard match is 00:00:00:00:00:00 - %allowed_wiimote_adr=00:00:00:00:00:00 - % my set of wiimotes - allowed_wiimote_adr=00:19:?D:??:6?:?? 00:1F:C5:??:??:?? 00:17:AB:39:69:87 - - % launching exe file have a problem with spaces, hence renamed exe, replaced space with underscores - % The original Johnny Chung Lee wb software version 0.3, downloaded from [http://johnnylee.net/projects/wii/] - % may not work yet, missing library integration - %whiteboard_software="d:/WiimoteWhiteboard/WiimoteWhiteboard_v0.3.exe" - - % same stuff, but binary build from sources and redistributed in this package - whiteboard_software="WiimoteWhiteboard.exe" - - % Boon Jin's wb software version 0.6, does not work yet, missing library integration - %whiteboard_software="d:/wsb/WiimoteSmoothboard.exe" - - % wiiscan parameters - %option_device="Nintendo RVL-CNT-01" - - % number of bt scanning attempts in a autoscan, timout is increased for every scan as retryattempt*option_timeout - option_scanretries=1 - - % long time (4000 and above, or increase option_scanretries) when matching name, short (1000-2000) when matching address - option_timeout=4000 - - % wiimote scanning time, only applicable used for wiilib - option_wiitimeout=1000 - - % delay bewteen powerdown/up, see man for details - option_usbsleep=1000 - option_usbmsleep=1000 - %option_btsleep=2000 - - % start wb at successfull connect, 0 or 1 - option_startwhiteboard=1 - - % output verbose flag, 0 or 1 - option_debug=1 - - % logging output file, put nothing if no logging is wanted - option_logfile=wiiscan_log.txt - %option_logfile= - - % wiimote connection library, use none, wiiuse, or wiimotelib - option_wiilib=wiimotelib - - % 0=no power cycle, 1=USB hub control, 2=USBm IO, 3=USB Devcon - option_usbpowermode=3 - - % 0=remove if not connectable, 1=always remove, 2=never remove - %option_forceremove=0 - - % bt radio to use, not working yet - %option_btradio=00:50:B6:A0:48:8C - - % wiiscantray options - % number of connection attempts before autoscan i restarted - option_tray_pool_retries=2 - - % retry sleep, keep it low (<1000) to catch an open connection - option_tray_sleep_between_pool_retries=250 - - % sleep bewteen polls, when wiimote is succeful connected, keep it hight (>2000) to avoid to much CPU usage - option_tray_sleep_between_pool_loops=2000 - - % final connection step reqires some sleep before windows PnP is ready - option_sleep_before_final_connect=1500 - - % delay after launch of wb software, keep it at a medium value (2000-10000) - option_sleep_after_startwhiteboard=4000 -% Configfile_end diff --git a/cpp/wiiscan/Release/wiiuse.dll b/cpp/wiiscan/Release/wiiuse.dll deleted file mode 100644 index a7e228c..0000000 Binary files a/cpp/wiiscan/Release/wiiuse.dll and /dev/null differ diff --git a/java/native/list.exe b/java/native/list.exe index 8fbe93a..17d5b4f 100644 Binary files a/java/native/list.exe and b/java/native/list.exe differ