Passing Argument to Delphi exe application

I want to write delphi application and get outside parameters
in C++ I use args variable from

 WINAPI WinMain(HINSTANCE, HINSTANCE hInstance, LPSTR args, int)
{
}

but in delphi (2005) there is no function like this

Can someone help me.

---------
Thanks
xtrueAsked:
Who is Participating?
 
Russell LibbySoftware Engineer, Advisory Commented:

Delphi exposes the following which lets you work with the command line / arguments for the running process:

- CmdLine variable
- ParamCount function
- ParamStr function

Example from the Delphi help (D5)

procedure TForm1.FormCreate(Sender: TObject);

var
  i: Integer;
  for i := 0 to ParamCount – 1 do
  begin
    if LowerCase(ParamStr(i)) = 'beep' then
      Beep(10000,1000)
    else if (LowerCase(ParamStr(i)) = 'exit' then
      Application.Terminate;
  end;
end;

------

Regards,
Russell
0
 
xtrueAuthor Commented:
THanks,

another thing, Why my file's name (pass as argument) look like

C:\Docu~1\xxxx\Desktop\abc~TXT.bit

????

I want it to completely correct, I use

HKEY_CLASSES_ROOT\*\shell\My Command\command
(default) is %Path%/My App/myapp.exe %1

Please help me again

-----------
Thanks!
0
 
Russell LibbySoftware Engineer, Advisory Commented:

// Exported from kernel32.dll in Win98 and higher
function GetLongPathName(lpszShortPath: PChar; lpszLongPath: PChar; cchBuffer: DWORD): DWORD; stdcall; external 'kernel32.dll' name 'GetLongPathNameA';

function GetLongFileName(FileName: String): String;
var  lpszFile:      Array [0..MAX_PATH] of Char;
begin

  // Get long path name
  SetString(result, lpszFile, GetLongPathName(PChar(FileName), @lpszFile, MAX_PATH));

end;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.