November 14th, 2012, 07:26 AM
Import a .dll (NirCmd.DLL)
I'm trying to import a dll file to Delphi. The dll file is called NirCmd.dll and is used to control some features on a windows pc. A simple google search for "nircmd.dll" will take you to the site..
On the website it explains how to use the dll:
NirCmd DLL is a sample dll that you can call in order to execute NirCmd Commands.
nircmd.dll exports only one function:
BOOL WINAPI DoNirCmd(LPSTR lpszCommand)
The function accepts one parameter containing the NirCmd command, and returns True (1) on success, and False (0) on failure.
I'm having problems to run the DoNirCmd function from Delphi.
My code is as follow:
function DoNirCmd(lpszCommand:string): bool; stdcall; external 'nircmd.dll';
When I call the function DoNirCmd('cdrom open') I receive an AV. Can anyone please help me to import this DLL in Delphi?
November 14th, 2012, 08:10 AM
try using PChar or PAnsiChar
function DoNirCmd(lpszCommand:PAnsiChar): bool; stdcall; external 'nircmd.dll';
November 14th, 2012, 10:22 AM
Thanks so much Bummi!
pansichar did the trick..