Procedure works under D2 but not under D5, Why ?

The following function under Delphi 2 ran another application with no problems, but since I moved to Delphi 5 it fails to compile.

function WinExec32(FileName:String; Visibility : integer):integer;
var
  zAppName:array[0..512] of char;
  zCurDir:array[0..255] of char;
  WorkDir:String;
  StartupInfo:TStartupInfo;
  ProcessInfo:TProcessInformation;
begin
     StrPCopy(zAppName,FileName);
     GetDir(0,WorkDir);
     StrPCopy(zCurDir,WorkDir);
     FillChar(StartupInfo,Sizeof(StartupInfo),#0);
     StartupInfo.cb := Sizeof(StartupInfo);

     StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
     StartupInfo.wShowWindow := Visibility;
     if not CreateProcess(nil, zAppName, nil, nil, false,
          CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil,
          StartupInfo, ProcessInfo)
     then
          Result := -1
     else
     begin
          WaitforSingleObject(ProcessInfo.hProcess,0);
          GetExitCodeProcess(ProcessInfo.hProcess,Result);  { This line Fails }
     end;
end;


It fails on the line mentioned with the following error message -
'Types of actual and formal var parameters must be identical'

I cannot find what could be causing it -  Any suggestions ?
chrisedenAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MadshiConnect With a Mentor Commented:
The declaration of GetExitCodeProcess has changed. In D2 the 2nd parameter was "var integer", now it is "var cardinal". You have 2 choices now.
(1) Change the result type of your WinExec32 function to "cardinal" or
(2) Use this:
GetExitCodeProcess(ProcessInfo.hProcess, cardinal(Result));

Regards, Madshi.

P.S: In D2+3 cardinal was just a subtype of integer (something like (0..maxInt = 0..$7FFFFFFF)). In D4+5 cardinal is a real unsigned dword (0..$FFFFFFFF).
0
 
chrisedenAuthor Commented:
Thank you, a lot more simpe then I thought.  All the help files still say that it is an integer.
0
 
MadshiCommented:
If you have such kind of compiler errors, it is the best way to go with the cursor after the first bracket, then enter a "(" and delete it again. Delphi now precompiles your project and shows you the *real* parameters in a little hint window. You can rely in that, unfortunately you can't always rely on the help.
0
 
chrisedenAuthor Commented:
I forgot the hint window. There are a lot of improvements from Delphi 2 and I am only beginning to get used to Delphi 5.

Many Thanks
0
 
MadshiCommented:
Well, here are the changes that were most important for me:

- wideString handling
- interfaces (and TInterfacedObject)
- dynamic arrays
- predefined parameters
- function / method overloading
- int64
0
All Courses

From novice to tech pro — start learning today.