Español
Foro

Current Directory encima API ändern

 
¡Hola todos zusammen...

Yo búsqueda möglichst viele Möglichkeiten, encima el Windows API el aktuelle Directorio uno Prozesses a ändern. Wer ha Ideen? Auch Ausgefallenes erwünscht...
 
25.08.2006  
 



Das aktuelle Directorio gilt para todos Prozesse y puede ser así conjunto:
KompilierenMarcaSeparación
Oder media Usted qué más?
 
25.08.2006  
 



Sí, así qué, bloß laut WIN32.HLP:
Each process has a single current directory made up of two parts:
Lo wäre muy schlimm, si todos Prozesse el gleiche Current Direktory hätten, porque en LoadLibrary es:
If a path is not specified and the filename extension is omitted, the default library extension .DLL is appended. However, the filename cadena can include a trailing point character (.) to indicate that the module name has no extension. When no path is specified, the function searches for the file en the following sequence:

1.The directory from which the application loaded.
2.The current directory.
3.Windows 95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.

Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.

4.Windows NT only: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.
5.The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6.The directories that are listed en the PATH environment variable.

Yo brauche möglichst viele Möglichkeiten, el aktuellen Pfad a ändern - tener qué bestimmtes antes y búsqueda qué passendes - o. algo Yo me passend hacer kann...
 
25.08.2006  
 



Jepp, como dijo - si el así wäre, wäre el fatal...
 
25.08.2006  
 



Haste Recht, aber esta es a bedenken, el el Pfad en Aufruf encima Shell oder Verknüpfung, en el el Pfad no eingetragen wurde, el zuletzt vom Sistema verwendeten entspricht!
Das CurrentDirectory se also no siempre autom. en el Pfad el Exe gesetzt, pero sólo en Doppelclick, si Ausführen en en el Link angegeben es oder el Pfad en ShellExecute con angegeben wurde.
 
25.08.2006  
 



So, Yo muß wohl doch sagen, wozu Yo el brauche:
Yo möchte una fremden Prozess dazu bringen - sin Schreibrechte en esta Prozess a besitzen - una DLL a invitar.
Es sólo, si yo el Current Directory dieses Prozesses ändere. Dafür necesidad Yo möglichst una API (evtl. una Diálogo), el como ersten Parámetro una Fensterhandle ha...
 
25.08.2006  
 




Frank
Abbing
Hab qué gefunden, tal vez bringt lo dir qué.
Testen voluntad Yo morgen otra vez para dich. Heute me está qué dazwischen gekommen: Bin heute Onkel geworden


- Microsoft Win32 Software Development Kit (SDK) for Windows NT,
versions 3.1 and 3.5

SUMMARY

To find the filename of the program that created a given window under
Windows, you would use GetWindowLong(hWnd, GWL_HINSTANCE) to find the
module handle and then GetModuleFileName() to find the filename. This
method cannot be used under Windows NT because instance handles are not
global, but are unique to the address space en which the application is
running.

If the application that created the window is a Windows-based application,
the name returned is ntvdm. To get the actual filename, you need to spawn

a Win16 application that voluntad call GetModuleFileName() and pass the
filename back to your application using some form of interprocess
communication (IPC).

MORE INFORMATION

To find the filename of a application once you have its window handle,
first use GetWindowThreadProcessId() to find the process ID (PID) of the
process that created the window. Using the PID, query the registry for the
performance data associated with the process. To do this, you have to
enumerate all processes en the system, comparing each PID to the PID of the
process that you are looking for, until the data for that process is found.
(This data includes the name of the process.)

The following sample code demonstrates how to find the filename of the
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 name of Program Managers executable file.

printf( Searching for filename of Program Manager...
);
DisplayFilename( dwActiveProcessId );
}

/********************************************************************
* Function: void DisplayFilename( DWORD ) *

* *
* Purpose : Display executable filename of the process whose PID *
* is passed en as a parameter. *
* *
* Comment : The information is retrieved from the performance *
* data en the 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 the index for the PROCESS object.
GetIndex( Process, szIndex );

// Get memory for PPERF_DATA_BLOCK.
pdb = (PPERF_DATA_BLOCK) HeapAlloc( GetProcessHeap(),
HEAP_ZERO_MEMORY,
dwBytes);

// Get performance data.
mientras 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 the first counter definition.
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++ )
{
if (pcd->CounterNameTitleIndex == (DWORD)atoi(szIndex))
{
dwProcessIdOffset = pcd->CounterOffset;
break;
}

pcd = ((PPERF_COUNTER_DEFINITION)((PBYTE)pcd + pcd->ByteLength));

}

// Get the first instance of the object.
pid = (PPERF_INSTANCE_DEFINITION)((PBYTE)pot + pot-
>DefinitionLength);

// Get the name of the first process.
pcb = (PPERF_COUNTER_BLOCK) ((PBYTE)pid + pid->ByteLength );
CurrentProcessId = *((DWORD *) ((PBYTE)pcb + dwProcessIdOffset));

// Find the process object for PID passed en, then imprimir its
// filename.

for( i = 1; i < pot->NumInstances && bContinue; i++ )

{
if( CurrentProcessId == dwProcessId )
{
printf( The filename is %ls.exe.
,
(char *) ((PBYTE)pid + pid->NameOffset) );
bContinue = FALSE;
}
más
{
pid = (PPERF_INSTANCE_DEFINITION) ((PBYTE)pcb + pcb-
>ByteLength);
pcb = (PPERF_COUNTER_BLOCK) ((PBYTE)pid + pid->ByteLength);
CurrentProcessId = *((DWORD *)((PBYTE)pcb +
dwProcessIdOffset));

}
}
if( bContinue == TRUE )
printf( Not found. );

// Libre the allocated memory.
if( !HeapFree(GetProcessHeap(), 0, (LPVOID)pdb) )
printf( HeapFree failed en main.
);

// Cerrar handle to the key.
RegCloseKey( HKEY_PERFORMANCE_DATA );
}

/********************************************************************
* Function: void GetIndex( char *, char * ) *
* *

* Purpose : Get the index for the given counter *
* *
* Comment : The index is returned en the parameter 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 the key.
RegOpenKeyEx( HKEY_LOCAL_MACHINE,
Key,
0, KEY_READ,
&hKeyIndex );

// Get the size of the counter.
RegQueryValueEx( hKeyIndex,
Counters,
NULL, NULL, NULL,
&dwBytes );

// Allocate memory for the buffer.
pszBuffer = (char *) HeapAlloc( GetProcessHeap(),

HEAP_ZERO_MEMORY,
dwBytes );

// Get the titles and counters.
RegQueryValueEx( hKeyIndex,
Counters,
NULL, NULL,
(LPBYTE)pszBuffer,
&dwBytes );

// Find the index value for PROCESS.
pszTemp = pszBuffer;

mientras que( i != (int)dwBytes )
{
mientras que (*(pszTemp+i) != )

{
szIndex[j] = *(pszTemp+i);
i++;
j++;
}
szIndex[j] = ;
i++;
j = 0;
mientras que (*(pszTemp+i) != )
{
szObject[j] = *(pszTemp+i);
i++;
j++;
}
szObject[j] = ;
i++;
j = 0;
if( *(pszTemp+i) == )
i++;
if( strcmp(szObject, pszCounter) == 0 )
break;

}

// Deallocate the memory.
HeapFree( GetProcessHeap(), 0, (LPVOID)pszBuffer );

// Cerrar the key.
RegCloseKey( hKeyIndex );
}

REFERENCES

For more information on working with the performance data, please see one
or all of the following references:

- The Win32 Programmers Reference.

- The Windows NT Resource Kit, volume 3.

- The source code for PView that is included en the Win32 SDK.

- The Windows/MS-DOS Developers Journal, April 1994.

Additional reference words: 3.10 3.50 file name
KBCategory: kbprg
KBSubcategory: BseMisc
 
25.08.2006  
 



Herzlichen Glückwunsch!
 
25.08.2006  
 




Frank
Abbing
Gracias y Gute Nacht!
 
25.08.2006  
 



Respuesta


Título del Tema, max. 100 Signo.
 

Systemprofile:

Kein Systemprofil creado. [anlegen]

XProfan:

 Contribución  Font  Smilies  ▼ 

Bitte registro en una Contribución a verfassen.
 

Tema opciones

1.433 Views

Untitledvor 0 min.
Gary1234513.06.2013
Andre Rohland13.03.2013

Themeninformationen

Dieses Thema ha 2 subscriber:

unbekannt (7x)
Frank Abbing (2x)


Admins  |  AGB  |  Applications  |  Autores  |  Chat  |  Política de Privacidad  |  Descargar  |  Entrance  |  Ayuda  |  Merchantportal  |  Pie de imprenta  |  Mart  |  Interfaces  |  SDK  |  Services  |  Juegos  |  Búsqueda  |  Support

Ein Projekt aller XProfan, el lo son!


Mi XProfan
Privado Noticias
Eigenes Ablageforum
Temas-Merkliste
Eigene Beiträge
Eigene Temas
Zwischenablage
Cancelar
 Deutsch English Français Español Italia
Traducciones

Política de Privacidad


Wir uso Cookies sólo como Session-Cookies wegen el technischen Notwendigkeit y en uns hay no Cookies de Drittanbietern.

Wenn du hier en unsere Webseite klickst oder navigierst, stimmst du unserer Erfassung de Informationen en unseren Cookies en XProfan.Net a.

Weitere Informationen a unseren Cookies y dazu, como du el Kontrolle darüber behältst, findest du en unserer nachfolgenden Datenschutzerklärung.


einverstandenDatenschutzerklärung
Yo möchte no Cookie