Einzelnen Beitrag anzeigen

Benutzerbild von divBy0
divBy0

Registriert seit: 4. Mär 2007
Ort: Sponheim
1.021 Beiträge
 
Delphi XE2 Professional
 
#1

Benötige Hilfe bei der Nutzung einer DLL

  Alt 4. Sep 2012, 23:20
Hallo zusammen,

ich habe eine DLL um Daten mit einem externen Gerät auszutauschen. Eine Beispielanwendung in VB ist dabei, allerdings funktioniert diese nicht.

Hier mal ein Ausschnitt aus der DLL:

Code:
#pragma once

#ifdef LKIF2_EXPORTS
#define EXP __declspec(dllexport)
#else
#define EXP __declspec(dllimport)
#endif

#include "Winsock2.h"

// Return Code List
typedef enum {   
   RC_OK = 0x0000,            // The operation is completed successfully.
   ///////////////////////////////////////////////
   // Communication error from controller notification
   //
   RC_NAK_COMMAND = 0x1001,   // Command error
   RC_NAK_COMMAND_LENGTH,      // Command length error
   RC_NAK_TIMEOUT,            // Timeout
   RC_NAK_CHECKSUM,         // Check sum error
   RC_NAK_INVALID_STATE,      // Status error
   RC_NAK_OTHER,            // Other error
   RC_NAK_PARAMETER,         // Parameter error
   RC_NAK_OUT_STAGE,         // OUT calculation count limitation error
   RC_NAK_OUT_HEAD_NUM,      // No. of used head/OUT over error
   RC_NAK_OUT_INVALID_CALC,   // OUT which cannot be used for calculation was specified for calculation.
   RC_NAK_OUT_VOID,         // OUT which specified for calculation is not found.
   RC_NAK_INVALID_CYCLE,      // Unavailable sampling cycle
   RC_NAK_CTRL_ERROR,         // Main unit error
   RC_NAK_SRAM_ERROR,         // Setting value error
   ///////////////////////////////////////////////
   // Communication DLL error notification
   //
   RC_ERR_OPEN_DEVICE = 0x2000,// Opening the device failed.
   RC_ERR_NO_DEVICE,         // The device is not open.
   RC_ERR_SEND,            // Command sending error
   RC_ERR_RECEIVE,            // Response receiving error
   RC_ERR_TIMEOUT,            // Timeout
   RC_ERR_NODATA,            // No data
   RC_ERR_NOMEMORY,         // No free memory
   
   RC_ERR_DISCONNECT,         // Cable disconnection suspected
   RC_ERR_UNKNOWN,            // Undefined error
} RC;   

extern "C"
{
///////////////////////////////////////////////
// Other commands
//
// Opens the USB device.
EXP RC WINAPI LKIF2_OpenDeviceUsb();
// Closes the currently open device.
EXP RC WINAPI LKIF2_CloseDevice();
}
Der Datentyp RC sieht bei mir so aus:

Delphi-Quellcode:
TKeyenceRC = (
              // Return Code List
              RC_OK = $0000,            // The operation is completed successfully.
              ///////////////////////////////////////////////
              // Communication error from controller notification
              //
              RC_NAK_COMMAND = $1001,   // Command error
              RC_NAK_COMMAND_LENGTH,      // Command length error
              RC_NAK_TIMEOUT,            // Timeout
              RC_NAK_CHECKSUM,         // Check sum error
              RC_NAK_INVALID_STATE,      // Status error
              RC_NAK_OTHER,            // Other error
              RC_NAK_PARAMETER,         // Parameter error
              RC_NAK_OUT_STAGE,         // OUT calculation count limitation error
              RC_NAK_OUT_HEAD_NUM,      // No. of used head/OUT over error
              RC_NAK_OUT_INVALID_CALC,   // OUT which cannot be used for calculation was specified for calculation.
              RC_NAK_OUT_VOID,         // OUT which specified for calculation is not found.
              RC_NAK_INVALID_CYCLE,      // Unavailable sampling cycle
              RC_NAK_CTRL_ERROR,         // Main unit error
              RC_NAK_SRAM_ERROR,         // Setting value error
              ///////////////////////////////////////////////
              // Communication DLL error notification
              //
              RC_ERR_OPEN_DEVICE = $2000,// Opening the device failed.
              RC_ERR_NO_DEVICE,         // The device is not open.
              RC_ERR_SEND,            // Command sending error
              RC_ERR_RECEIVE,            // Response receiving error
              RC_ERR_TIMEOUT,            // Timeout
              RC_ERR_NODATA,            // No data
              RC_ERR_NOMEMORY,         // No free memory

              RC_ERR_DISCONNECT,         // Cable disconnection suspected
              RC_ERR_UNKNOWN            // Undefined error
             );
Die beiden Funktionen sehen bei mir aktuell so aus:

Delphi-Quellcode:
const
  DLLNAME = 'LKIF2.dll';

function LKIF2_OpenDeviceUsb: TKeyenceRc; stdcall; external DLLNAME;
function LKIF2_CloseDevice: TKeyenceRC; stdcall; external DLLNAME;
Ist das so korrekt? Fehler bekomme ich nämlich keine beim Aufruf, einzig im ProcessMonitor wird mir beim Aufruf der Funktionen "NAME NOT FOUND" angezeigt (siehe ProcessMonitor.png).

Kann mir da vielleicht jemand was zu sagen?

Danke
Miniaturansicht angehängter Grafiken
processmonitor.png  
Marc
9 von 10 Stimmen in meinem Kopf sagen ich bin nicht verrückt, die 10. summt die Melodie von Tetris... | Wenn das die Lösung ist, dann hätte ich gerne mein Problem zurück! | engbarth.es
  Mit Zitat antworten Zitat