| |
|
|
| allô alle zusammen...
je cherche possible viele Opportunités, sur qui Windows API cela aktuelle Verzeichnis eines Prozesses trop changement. qui hat idées? aussi Ausgefallenes erwünscht... |
|
|
| |
|
|
|
| |
|
| |
|
|
|
| oui, so quoi, bloß le son WIN32.HLP: Each process has a single current directory asticot up of two parts: Es wäre très grave, si alle Prozesse qui gleiche Current Direktory hätten, car chez LoadLibrary steht:
Si a path is not specified and le filename extension is omitted, le default library extension .DLL is appended. However, le filename string can include a trailing point character (.) to indicate that le module nom has no extension. When no path is specified, le function searches for le file dans le following sequence:
1.The directory à partir de which le application loaded. 2.The current directory. 3.Windows 95: The Windows system directory. Use le GetSystemDirectory function to get le path of this directory.
Windows NT: The 32-bit Windows system directory. Use le GetSystemDirectory function to get le path of this directory. The nom of this directory is SYSTEM32.
4.Windows NT only: The 16-bit Windows system directory. There is no Win32 function that obtains le path of this directory, but il is searched. The nom of this directory is SYSTEM. 5.The Windows directory. Use le GetWindowsDirectory function to get le path of this directory. 6.The directories that sont listed dans le PATH environment variable.
il me faut possible viele Opportunités, den aktuellen Pfad trop changement - hab quoi bestimmtes avant et cherche quoi passendes - bzw. quelque chose quoi je mir convenable faire peux... |
|
|
| |
|
|
|
| Jepp, comment dit - si dem so wäre, wäre cela fatal... |
|
|
| |
|
|
|
| Haste droite, mais dabei ist trop considérer, cela qui Pfad chez Aufruf sur Shell ou bien Verknüpfung, dans qui qui Pfad pas eingetragen wurde, dem zuletzt vom System verwendeten entspricht! cela CurrentDirectory wird alors pas toujours autom. sur den Pfad qui Exe gesetzt, mais seulement chez Doppelclick, si Effectuer dans im Link angegeben ist ou bien qui Pfad chez ShellExecute avec angegeben wurde. |
|
|
| |
|
|
|
| So, je dois wohl doch dire, wozu je cela brauche: je voudrais une fremden Prozess en supplément apporter - sans Schreibrechte sur cette Prozess trop besitzen - une DLL trop magasin. cela allez seulement, si je qui Current Annuaire cet Prozesses ändere. Pour cette besoin je possible une API (peut-être. une Dialog), qui comme ersten paramètre un Fensterhandle hat... |
|
|
| |
|
|
|
Frank Abbing | Hab quoi trouvé, peut-être bringt es dir quoi. Testen werde je demain wieder pour toi. aujourd'hui c'est moi quoi entre gekommen: suis aujourd'hui oncle geworden
- Microsoft Win32 Software Development Kit (SDK) for Windows NT, versions 3.1 and 3.5
SUMMARY
To find le filename of le program that created a given window under Windows, you would use GetWindowLong(hWnd, GWL_HINSTANCE) to find le module handle and then GetModuleFileName() to find le filename. This method cannot être used under Windows NT because instance handles sont not global, but sont unique to le address space dans which le application is running.
Si le application that created le window is a Windows-based application, le nom returned is ntvdm. To get le actual filename, you need to spawn
a Win16 application that veux call GetModuleFileName() and pass le filename back to your application using some forme of interprocess communication (IPC).
MORE INFORMATION
To find le filename of à application once you have its window handle, first use GetWindowThreadProcessId() to find le process ID (PID) of le process that created le window. Using le PID, query le registry for le performance data associated with le process. To do this, you have to enumerate espace processes dans le system, comparing each PID to le PID of le process that you sont looking for, until le data for that process is found. (This data includes le nom of le process.)
The following sample code demonstrates how to find le filename of le Program Manager, PROGMAN.EXE, after obtaining its window handle:
Sample Code -----------
#include #include #include
#define Key SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009
void GetIndex( char *, char * ); void DisplayFilename( DWORD );
/********************************************************************
* Function: void main( ) * * * * Purpose : Application entry point * * *
void main( ) { HWND hWnd; DWORD dwActiveProcessId;
// Get window handle of Program Managers main window.
hWnd = FindWindow( Progman, NULL );
// Get PID of Program Manager.
GetWindowThreadProcessId( hWnd, &dwActiveProcessId );
// Display nom of Program Managers executable file.
printf( Searching for filename of Program Manager... ); DisplayFilename( dwActiveProcessId ); }
/******************************************************************** * Function: void DisplayFilename( DWORD ) *
* * * Purpose : Display executable filename of le process whose PID * * is passed dans as a paramètre. * * * * Comment : The information is retrieved à partir de le performance * * data dans le registry. * * *
void DisplayFilename( DWORD dwProcessId ) { DWORD CurrentProcessId; BOOL bContinue = TRUE; char szIndex[256] = ; DWORD dwBytes = 12000; DWORD dwProcessIdOffset; int i;
PPERF_DATA_BLOCK pdb; PPERF_OBJECT_TYPE pot; PPERF_INSTANCE_DEFINITION pid; PPERF_COUNTER_BLOCK pcb;
PPERF_COUNTER_DEFINITION pcd;
// Get le index for le PROCESS object. GetIndex( Process, szIndex );
// Get memory for PPERF_DATA_BLOCK. pdb = (PPERF_DATA_BLOCK) HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwBytes);
// Get performance data. tandis que( RegQueryValueEx(HKEY_PERFORMANCE_DATA, (LPTSTR)szIndex, NULL, NULL, (LPBYTE)pdb, &dwBytes) ==
ERROR_MORE_DATA ) { // Increase memory. dwBytes += 1000;
// Allocated memory is too small; reallocate new memory. pdb = (PPERF_DATA_BLOCK) HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, (LPVOID)pdb, dwBytes); }
// Get PERF_OBJECT_TYPE. pot = (PPERF_OBJECT_TYPE)((PBYTE)pdb + pdb->HeaderLength);
// Get le first counter définition. pcd = (PPERF_COUNTER_DEFINITION)((PBYTE)pot + pot->HeaderLength);
// Get index value for ID_PROCESS. szIndex[0] = ; GetIndex( ID Process, szIndex );
for( i=0; i< (int)pot->NumCounters; i++ ) { si (pcd->CounterNameTitleIndex == (DWORD)atoi(szIndex)) { dwProcessIdOffset = pcd->CounterOffset; break; }
pcd = ((PPERF_COUNTER_DEFINITION)((PBYTE)pcd + pcd->ByteLength));
}
// Get le first instance of le object. pid = (PPERF_INSTANCE_DEFINITION)((PBYTE)pot + pot- >DefinitionLength);
// Get le nom of le first process. pcb = (PPERF_COUNTER_BLOCK) ((PBYTE)pid + pid->ByteLength ); CurrentProcessId = *((DWORD *) ((PBYTE)pcb + dwProcessIdOffset));
// Find le process object for PID passed dans, then imprimer its // filename.
for( i = 1; i < pot->NumInstances && bContinue; i++ )
{ si( CurrentProcessId == dwProcessId ) { printf( The filename is %ls.exe. , (char *) ((PBYTE)pid + pid->NameOffset) ); bContinue = FALSE; } d'autre { pid = (PPERF_INSTANCE_DEFINITION) ((PBYTE)pcb + pcb- >ByteLength); pcb = (PPERF_COUNTER_BLOCK) ((PBYTE)pid + pid->ByteLength); CurrentProcessId = *((DWORD *)((PBYTE)pcb + dwProcessIdOffset));
} } si( bContinue == TRUE ) printf( Not found. );
// Free le allocated memory. si( !HeapFree(GetProcessHeap(), 0, (LPVOID)pdb) ) printf( HeapFree failed dans main. );
// Fermer handle to le clé. RegCloseKey( HKEY_PERFORMANCE_DATA ); }
/******************************************************************** * Function: void GetIndex( char *, char * ) * * *
* Purpose : Get le index for le given counter * * * * Comment : The index is returned dans le paramètre szIndex * * *
void GetIndex( char *pszCounter, char *szIndex ) { char* pszBuffer; char* pszTemp; char szObject[256] = ; DWORD dwBytes; HANDLE hKeyIndex;
int i = 0; int j = 0;
// Open le clé. RegOpenKeyEx( HKEY_LOCAL_MACHINE, Key, 0, KEY_READ, &hKeyIndex );
// Get le size of le counter. RegQueryValueEx( hKeyIndex, Counters, NULL, NULL, NULL, &dwBytes );
// Allocate memory for le buffer. pszBuffer = (char *) HeapAlloc( GetProcessHeap(),
HEAP_ZERO_MEMORY, dwBytes );
// Get le titles and counters. RegQueryValueEx( hKeyIndex, Counters, NULL, NULL, (LPBYTE)pszBuffer, &dwBytes );
// Find le index value for PROCESS. pszTemp = pszBuffer;
tandis que( i != (int)dwBytes ) { tandis que (*(pszTemp+i) != )
{ szIndex[j] = *(pszTemp+i); i++; j++; } szIndex[j] = ; i++; j = 0; tandis que (*(pszTemp+i) != ) { szObject[j] = *(pszTemp+i); i++; j++; } szObject[j] = ; i++; j = 0; si( *(pszTemp+i) == ) i++; si( strcmp(szObject, pszCounter) == 0 ) break;
}
// Deallocate le memory. HeapFree( GetProcessHeap(), 0, (LPVOID)pszBuffer );
// Fermer le clé. RegCloseKey( hKeyIndex ); }
REFERENCES
For more information on working with le performance data, please lac one or espace of le following references:
- The Win32 Programmers Reference.
- The Windows NT Resource Kit, volume 3.
- The source code for PView that is included dans le Win32 SDK.
- The Windows/MS-DOS Developers journal, avril 1994.
Additional reference words: 3.10 3.50 file nom KBCategory: kbprg KBSubcategory: BseMisc |
|
|
| |
|
|
|
| Herzlichen Glückwunsch! |
|
|
| |
|
|
|
Frank Abbing | |
|
| |
|
|