![]() |
DLL - C nach Delphi konvertieren
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo liebe Community,
bei der Übersetzung eines Headers für den Zugriff auf eine DLL scheint ein Fehler zu sein...zumindest funktioniert nur ein Teil der Kommandos... Auszug aus der DobotDll.h Datei:
Code:
und Auszug aus der DobotType.h Datei
#ifndef DOBOTDLL_H
#define DOBOTDLL_H #include "DobotType.h" ... extern "DobotDll.dll" int SetPTPCmd(PTPCmd *ptpCmd, bool isQueued, uint64_t *queuedCmdIndex); ... #endif // DOBOTDLL_H
Code:
...dann noch ein weiterer Auszug aus einem C# Beispiel:
#ifndef DOBOTTYPE_H
#define DOBOTTYPE_H #ifdef _MSC_VER typedef unsigned char uint8_t; typedef signed char int8_t; typedef unsigned short uint16_t; typedef signed short int16_t; typedef unsigned int uint32_t; typedef signed int int32_t; typedef unsigned long long uint64_t; typedef signed long long int64_t; #else #include <stdint.h> #endif ... #pragma pack(push) #pragma pack(1) ... typedef struct tagPTPCmd { uint8_t ptpMode; float x; float y; float z; float r; }PTPCmd; ... #pragma pack(pop) #endif DobotDllType.cs
Code:
und aus der Dobot.cs
using System;
using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; namespace DobotClientDemo.CPlusDll ... [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] public struct PTPCmd { public byte ptpMode; public float x; public float y; public float z; public float rHead; }; ... }
Code:
using System;
using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; namespace DobotClientDemo.CPlusDll ... [DllImport("DobotDll.dll", EntryPoint = "SetPTPCmd", CallingConvention = CallingConvention.Cdecl)] public static extern int SetPTPCmd(ref PTPCmd playbackCmd, bool isQueued, ref UInt64 queuedCmdIndex); ... } ...an sich alles kein Problem, nun der übersetzte Part in Delphi:
Delphi-Quellcode:
...ist da irgendwo ein Fehler?
unit UDobot_Interface;
interface type ... TPTPCmd = record ptpMode: Byte; x: single; y: single; z: single; r: single; end; PPTPCmd = ^TPTPCmd; ... function SetPTPCmd ( ptpCmd: PPTPCmd; isQueued: Boolean; queuedCmdIndex: puint64 ): Integer; cdecl; ... implementation ... //extern "C" int SetPTPCmd(PTPCmd *ptpCmd, bool isQueued, uint64_t *queuedCmdIndex); function SetPTPCmd ( ptpCmd: PPTPCmd; isQueued: Boolean; queuedCmdIndex: puint64 ): Integer; cdecl; external 'DobotDll.dll'; ... end. Danke für Hinweise Grüße |
AW: DLL - C nach Delphi konvertieren
Hast Du es mal mit packed record versucht?
|
AW: DLL - C nach Delphi konvertieren
Zitat:
Ersetze "Boolean" durch "LongBool".
Delphi-Quellcode:
TPTPCmd = packed record
|
AW: DLL - C nach Delphi konvertieren
Hallo zusammen,
vielen Dank für die schnellen Antworten: Ersetzen von Boolean durch LongBool und ein packed dazu hat Wunder gewirkt. Läuft :thumb: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:46 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz