Link to home
Start Free TrialLog in
Avatar of Anthem
Anthem

asked on

Executing .reg file

Hi Experts,

I am wanting to execute a .reg file w/o the message "Information in '.reg file' has been successfully entered into the registry".  How would I do this programatically?  Also, I understand that the WinExec function returns automatically w/o completion of the running program to execute the next line of code.  How do you use the ShellExecuteExe function to wait until the running program finishes to execute the next line of code?  I will need a detailed explanation of the ShellExecuteExe function because I have never used it before.  I appreciate your help in advance.

-Thanks :0)

Anthem
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
However, if you 'insist' in using 'ShellExecuteEx()', use

LONG    APIENTRY    LoadRegFile (   LPSTR pszRegFile)
{
    SHELLEXECUTEINFO sei;
   
    ZeroMemory  (   &sei,   sizeof  (   sei));

    sei.cbSize          =   sizeof  (   sei);  
    sei.fMask           =   SEE_MASK_NOCLOSEPROCESS ;
    sei.lpVerb          =   "open";
    sei.lpFile          =   pszRegFile;
    sei.lpParameters    =   "/s";
    sei.nShow           =   SW_HIDE;

    bRes    =   ShellExecuteEx  (   &sei);

    if  (   bRes)
        {
            WaitForSingleObject (   sei.hProcess,    INFINITE);

            CloseHandle (   sei.hProcess);

            return  (   0);
        }
     else   return  (   GetLastError());


    return  (   0);
}
Avatar of Anthem
Anthem

ASKER

jkr,

Worked perfectly.  I did use the CreateProcess() function.  Truly appreciate all of your help on this! :0)

Thank you so much,

Anthem :0)

-Have a great rest of the day
Rest of the day? 11:35pm here, so I really hope that the last (next) 25 minutes will be great ;-)
Avatar of Anthem

ASKER

Hehehehe, you are too cute.  Have a lot more of the day to go here.  Hope the rest of your 25 minutes goes wonderfully, and hope you have a great rest of the week, lol :0)