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,C REATE_DEFA ULT_ERROR_ MODE|CREAT E_SUSPENDE D,NULL, NULL, &StartupInfo, &ProcessInformation);
WaitForSingleObject( ProcessInformation.hProces s, 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
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,C
WaitForSingleObject( ProcessInformation.hProces
}
//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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.