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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadshiCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.