Link to home
Start Free TrialLog in
Avatar of davinder101
davinder101

asked on

problem withCreateProcess

Hi All
I am having a problem in my application, what I am doing is:
Calling a function SaveKeys(TCHAR *) within a loop and this function save the specified registry key to a .reg file,
for this using CreateProcess( ) for calling regedit.exe from command line and WaitForSingleObject( ) function.
code looks like this

for (int i = 0; i < 10; i++)
{
// some code here
SaveKeys(cRegistryKey ); // for specified Registry Key
}

void MyClass::SaveKeys(TCHAR *cRegistryKey)
{
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;

CreateProcess(NULL, cCommand,NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE|CREATE_SUSPENDED,NULL, NULL, &StartupInfo, &ProcessInformation);
WaitForSingleObject( ProcessInformation.hProcess, INFINITE );

}
//e.g. Here cCommand = regedit /e C:\File.reg HKEY_CURRENT_USER\MyKey

Now what is my problem is that here WaitForSingleObject( ) function is not working. and only a single reg file is created.
and when use Sleep(1000) then all the 10 reg file are created.

So please tell me that how should I overcome this problem.

Please reply
Thanks
 
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial