#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Import a .dll (NirCmd.DLL)


    Hi

    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?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Augsburg Germany
    Posts
    12
    Rep Power
    0
    try using PChar or PAnsiChar

    function DoNirCmd(lpszCommand:PAnsiChar): bool; stdcall; external 'nircmd.dll';
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0
    Thanks so much Bummi!

    pansichar did the trick..

IMN logo majestic logo threadwatch logo seochat tools logo