Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

CreateProcessA


2 replies to this topic

Dave I

Dave I
  • Members
  • 195 posts

Posted 21 June 2001 - 10:31

I am converting a project from IS5.5 to ISWI.  In IS5.5 I use the HideAppAndWait function (From InstallSite Sources.)  Basically in my old script I prototyped the CreateProcessA, as follows:

prototype BOOL kernel32.CreateProcessA(POINTER, BYVAL STRING, POINTER, POINTER, BOOL, NUMBER, POINTER, POINTER, POINTER,   POINTER);  //And all is good.....

Now, in WinAPI.h (ISWI folder\script\isrt\include), the same API call is prototyped as:

prototype  BOOL KERNEL32.CreateProcessA(BYVAL STRING, BYVAL STRING, POINTER, POINTER, BOOL, NUMBER, POINTER, BYVAL STRING, POINTER, POINTER);

The 1st and 8th arguement types are different!  So when I use my old code:

CreateProcessA(NULL, szCommand + " " + szParameters, NULL, NULL, TRUE, 0, NULL, NULL, &siData, &piData)

I get the errors :  error C8039: '0' : string value required

Could someone please help me convert the API call to use the new prototype.

Thank you, Thank you...


Irina

Irina
  • Members
  • 227 posts

Posted 22 June 2001 - 18:57

Hi Dave,
It seema to me that it should be the same as in InstallShield5. I used it with InstallShield5.
Now I use this code in WI as a InstallScript:

app.h file
       
// In the global section paste the following:

#define STILL_ACTIVE    0x00000103L

//
// dwCreationFlag values (from WINBASE.H)
//

#define DEBUG_PROCESS               0x00000001
#define DEBUG_ONLY_THIS_PROCESS     0x00000002

#define CREATE_SUSPENDED            0x00000004

#define DETACHED_PROCESS            0x00000008

#define CREATE_NEW_CONSOLE          0x00000010

#define NORMAL_PRIORITY_CLASS       0x00000020
#define IDLE_PRIORITY_CLASS         0x00000040
#define HIGH_PRIORITY_CLASS         0x00000080
#define REALTIME_PRIORITY_CLASS     0x00000100

#define CREATE_NEW_PROCESS_GROUP    0x00000200
#define CREATE_UNICODE_ENVIRONMENT  0x00000400

#define CREATE_SEPARATE_WOW_VDM     0x00000800
#define CREATE_SHARED_WOW_VDM       0x00001000
#define CREATE_FORCEDOS             0x00002000

#define CREATE_DEFAULT_ERROR_MODE   0x04000000
#define CREATE_NO_WINDOW            0x08000000

    //prototype HHideAppAndWait(STRING, STRING, NUMBER);
    prototype BOOL kernel32.CreateProcessA(POINTER, STRING, POINTER,
              POINTER, BOOL, NUMBER, POINTER, POINTER, POINTER,
              POINTER);
    prototype BOOL kernel32.GetExitCodeProcess(NUMBER, POINTER);
    prototype NUMBER kernel32.WinExec(STRING, NUMBER);

   typedef STARTUPINFO
   begin
       NUMBER   cb;
       POINTER  lpReserved;
       POINTER  lpDesktop;
       POINTER  lpTitle;
       NUMBER   dwX;
       NUMBER   dwY;
       NUMBER   dwXSize;
       NUMBER   dwYSize;
       NUMBER   dwXCountChars;
       NUMBER   dwYCountChars;
       NUMBER   dwFillAttribute;
       NUMBER   dwFlags;
       // the following is actually two words, but we know
       // we want 0 as the value, so we cheat & create one NUMBER
       NUMBER    wShowWindow;
       //WORD    cbReserved2;
       POINTER  lpReserved2;
       HWND  hStdInput;
       HWND  hStdOutput;
       HWND  hStdError;
   end;

   typedef PROCESS_INFORMATION
   begin
       NUMBER hProcess;
       HWND hThread;
       NUMBER dwProcessId;
       NUMBER dwThreadId;
   end;

function ...
STARTUPINFOsi;
PROCESS_INFORMATIONpi;    
STRING szCommand[126];  
NUMBERnExitCode;

.......
szCommand = "[PathToexefile] [Param]";

kernel32.CreateProcessA
                       (NULL,         //lpApplcationName
                      szCommand,  //lpCommandLine
                       NULL,//lpProcessAtrributes
                        NULL,//lpThreadAttributes
                        TRUE,//bInheritHandles
//CREATE_NEW_CONSOLE | CREATE_NO_WINDOW | HIGH_PRIORITY_CLASS,//dwCreationFlags
                     CREATE_NO_WINDOW,//dwCreationFlags
                        NULL,//lpEnvironment
                        NULL,//lpCurrentDirectory
                        &si,//lpStartupInfo
                        &pi);  

// wait finished apps
repeat                                
     kernel32.GetExitCodeProcess(pi.hProcess, &nExitCode);
   until (nExitCode != STILL_ACTIVE);

end

Good luck!


Dave I

Dave I
  • Members
  • 195 posts

Posted 25 June 2001 - 08:06

Thanks for the help Irena.   Because the API function had already been prototyped in WinAPI.h I couldnt add another prototype to my script without the compiler   moaning.

It seems that the InstallShield prototype does not allow NULLs.   I just omitted the first parameter, and passed a default directory for the 8th.  This is just my experience but I could be completely wrong of course.