English
Forum

Current Directory through API Change

 
hello everyone together...

I Search as many as possible Opportunities, over The Windows API the actually directory one Prozesses To Change. Who ideas? too Ausgefallenes erwünscht...
 
08/25/06  
 



the actually directory counts for all processes and can so settle:
CompileMarkSeparation
or mean You what other?
 
08/25/06  
 



Yes, so what, mere loudly WIN32.HLP:
Each process has a single current directory maggot up of two parts:
it would very bad, if any processes The same Current Direktory hätten, because with LoadLibrary standing:
If a path is hardship specified and the filename extension is omitted, the default library extension .DLL is appended. However, the filename string 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 in 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 in the PATH environment variable.

I need as many as possible Opportunities, whom actually Path to Change - Have what bestimmtes to and Search something suitable - or. something I me properly can make...
 
08/25/06  
 



Jepp, How said - if the so would, would the mortal...
 
08/25/06  
 



Haste right, but thereby is To deliberating, the the way with appeal over Shell or link, in the the way unregistered watts, the lastly of system verwendeten corresponds to!
the CurrentDirectory becomes means not always autom. on the way the Exe staid, separate only Doubleclick, if Perform in in the Link indicated is or the way with ShellExecute with indicated watts.
 
08/25/06  
 



so, I must well still say, wozu I the need:
i want a strangers Process moreover bring - without Schreibrechte on this Process To own - a DLL To loading.
the goes only, if I The Current Directory this Prozesses change. For this need I possible a API (evtl. a dialog), the as first Parameter one Fensterhandle has...
 
08/25/06  
 




Frank
Abbing
Have what found, Perhaps bring it to you what.
testing I will tommorrow again for you. today is me what between come: be today uncle become


- 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 lever and then GetModuleFileName() to find the filename. Diese
method cannot be used under windows NT because instance handles are hardship
global, but are unique to the address space in 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 wants call GetModuleFileName() and pass the
filename back to your application using some shape of interprocess
communication (IPC).

MORE INFORMATION

To find the filename of on application once you have its window lever,
ridge 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 in the system, comparing each PID to the PID of the
process that you are looking for, until the data for that process is found.
(Diese data includes the name of the process.)

The following sample code demonstrates how to find the filename of the
Program manager, PROGMAN.EXE, anus obtaining its window lever:

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 lever 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 in as a parameter. *
* *
* Comment : The information is retrieved from the performance *
* data in 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.
while( 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 in, then print 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;
}
else
{
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( hardship found. );

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

// Close lever 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 in 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;

while( i != (int)dwBytes )
{
while (*(pszTemp+i) != )

{
szIndex[j] = *(pszTemp+i);
i++;
j++;
}
szIndex[j] = ;
i++;
j = 0;
while (*(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 );

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

REFERENCES

For more information on working with the performance data, please sea 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 in the Win32 SDK.

- The windows/MS-DOS Developers journal, april 1994.

Additional reference words: 3.10 3.50 file name
KBCategory: kbprg
KBSubcategory: BseMisc
 
08/25/06  
 



cordial Glückwunsch!
 
08/25/06  
 




Frank
Abbing
thanks and good night!
 
08/25/06  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.448 Views

Untitledvor 0 min.
Gary1234506/13/13
Andre Rohland03/13/13

Themeninformationen

this Topic has 2 subscriber:

unbekannt (7x)
Frank Abbing (2x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie