Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Zitat von »"Bigmek"«
JA aber was mach ich dan mit dem Handel, das hatt bei mir nur ein element und mit dem kann ich nichts anfangen.
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
#include <iostream> #include <windows.h> #include <COMMCTRL.H> using namespace std; int main(int argc, char* argv[]) { HWND desktopHWND = GetDesktopWindow(); cout<<"Anzahl Icons auf Desktop: "<<ListView_GetItemCount(desktopHWND); return 0; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include <commctrl.h> HWND GetDesktopListView() { HWND hWnd = FindWindow( _T( "Progman" ), _T( "Program Manager" ) ); if ( hWnd ) { hWnd = FindWindowEx( hWnd, NULL, _T( "SHELLDLL_DefView" ), NULL ); if ( hWnd ) hWnd = FindWindowEx( hWnd, NULL, _T( "SysListView32" ), _T( "FolderView" ) ); } return hWnd; } // ... HWND hIconList = GetDesktopListView(); if ( hIconList ) { debugf( va( "%d Icons", ListView_GetItemCount( hIconList ) ) ); } |
Zitat von »"Bigmek"«
danke und was muss includen um es benutzen zu können?
Zitat von »"Bigmek"«
Und wie kann ich text oder position abfragen?
C-/C++-Quelltext |
|
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
#include <iostream> #include <windows.h> #include <COMMCTRL.H> #include <commctrl.h> using namespace std; // HWND GetDesktopListView() { HWND hWnd = FindWindow( "Progman" , "Program Manager" ); if ( hWnd ) { hWnd = FindWindowEx( hWnd, NULL,"SHELLDLL_DefView" , NULL ); if ( hWnd ) hWnd = FindWindowEx( hWnd, NULL, "SysListView32" , "FolderView" ); } return hWnd; } int main(int argc, char* argv[]) { HWND hIconList = GetDesktopListView(); if ( hIconList ) { cout<<"Anzahl Icons auf Desktop: "<<ListView_GetItemCount(hIconList)<<endl; int anzahl =ListView_GetItemCount(hIconList); LVITEM lvi, *_lvi; char item[512], subitem[512]; char *_item, *_subitem; unsigned long pid; HANDLE process; GetWindowThreadProcessId(hIconList, &pid); process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ| PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid); _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); _subitem=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvi.cchTextMax=512; for (int index = 0; index < anzahl; index++) { lvi.iSubItem=0; lvi.pszText=_item; WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); SendMessage(hIconList, LVM_GETITEMTEXT, (WPARAM)index, (LPARAM)_lvi); ReadProcessMemory(process, _item, item, 512, NULL); //printf("%s - %s\n", item, subitem); cout<<"Element"<<index<<": "<<item<<endl; } VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); VirtualFreeEx(process, _item, 0, MEM_RELEASE); VirtualFreeEx(process, _subitem, 0, MEM_RELEASE); anzahl = 0; } system("PAUSE"); return 0; } |
Werbeanzeige