![]() |
C++ DLL in Delphi einbinden
Ich habe eine C++ DLL, die ich in Delphi einbinden will, von der ich aber die Aufrufparameter nicht weiß.
Ich habe allerdings den C++ Quellcode. Nur leider komme ich da nicht weiter. Ich kann an dieser Stelle mit dem typedef und den enums nichts anfangen und weiß das in Delphi nicht umzusetzen. Wie definiere ich die 3 Funktionen in Delphi? PseudoDB* CreatePseudoDB(); void PseudoDB_Destroy(PseudoDB* pDB); int PseudoDB_LoadFromUSBRoot(PseudoDB* pDB,const wchar_t* sUSBRoot); wäre für einen Tip echt dankbar :coder2: Ich benutze Delphi 6 Hier der Quellcode-Auszug
Code:
typedef struct{} PseudoDB;
typedef struct{} PseudoTrack; typedef struct{} PseudoPlayList; enum { TrackStr_Album=0, TrackStr_Artist, TrackStr_Title, TrackStr_Genre, TrackStr_Comment, TrackStr_Composer, TrackStr_FileTypeDesc, TrackStr_Path, TrackStr_IPodPath, TrackStr_Count, }; enum { TrackInt_ID=0, TrackInt_FileSize, TrackInt_Duration, TrackInt_DiskNum, TrackInt_TotalDisks, TrackInt_TrackNum, TrackInt_TotalTracks, TrackInt_Year, TrackInt_Bitrate, TrackInt_VolumeAdjust, TrackInt_VolumeAdjustSoundCheck, TrackInt_CreatedTime, TrackInt_PlayedTime, TrackInt_ModifiedTime, TrackInt_Rating, TrackInt_PlayCount, TrackInt_PlayCountSinceSync, TrackInt_SampleRate, TrackInt_AppRating, TrackInt_BPM, TrackInt_Count, }; enum { PlayListStr_Name=0, PlayListStr_Count }; enum { PlayListInt_Type=0, PlayListInt_Count }; enum { PlayListType_Normal=0, PlayListType_Master=1, }; PseudoDB* CreatePseudoDB(); void PseudoDB_Destroy(PseudoDB* pDB); int PseudoDB_LoadFromUSBRoot(PseudoDB* pDB,const wchar_t* sUSBRoot); int PseudoDB_LoadFile(PseudoDB* pDB,const wchar_t* sFilename); |
Re: C++ DLL in Delphi einbinden
Code:
PseudoDB* CreatePseudoDB();
void PseudoDB_Destroy(PseudoDB* pDB); int PseudoDB_LoadFromUSBRoot(PseudoDB* pDB,const wchar_t* sUSBRoot);
Delphi-Quellcode:
function CreatePseudoDB():pPseudoDB;
procedure PseudoDB_Destroy( pDB:pPseudoDB );// oder procedure PseudoDB_Destroy( var pDB:PseudoDB ); function PseudoDB_LoadFromUSBRoot( pDB:pPseudoDB;const {wchar_t*} sUSBRoot: pwchar_t ):Integer; // oder //function PseudoDB_LoadFromUSBRoot( var pDB:PseudoDB;const {wchar_t*} sUSBRoot: pwchar_t ):Integer;
Code:
typedef struct{} PseudoDB;
typedef struct{} PseudoTrack; typedef struct{} PseudoPlayList;
Delphi-Quellcode:
type pPseudoDB = ^PseudoDB; PseudoDB = record end;
pPseudoTrack =^PseudoTrack; PseudoTrack = record end; pPseudoPlayList = ^PseudoPlayList; PseudoPlayList = record end; |
Re: C++ DLL in Delphi einbinden
Zitat:
|
Re: C++ DLL in Delphi einbinden
Ich bitte dich Luckie, es war nur ein Beitrag zur späten Stunde. Ich schreibe in Delphi sonst
![]() |
Re: C++ DLL in Delphi einbinden
Erstmal "Danke" für die Hilfe...
Leider klappt es noch nicht mit den DLL Aufrufen...es kommen ständig Zugriffsverletzungsfehler. Also zu meinem Verständnis.. Ich bekomme einen Pointer auf eine Struktur? (und diese Struktur ist leer? ) wchar_t ist übrigens so definiert -> typedef wchar_t const far*LPCWSTR; Kann ich dafür PChar nehmen? Ich habe das mal so versucht.. :gruebel:
Delphi-Quellcode:
.
. . type pPseudoDB = ^PseudoDB; PseudoDB = record end; function CreatePseudoDB():pPseudoDB; procedure PseudoDB_Destroy( pDB:pPseudoDB ); function PseudoDB_LoadFromUSBRoot( pDB:pPseudoDB; sUSBRoot: PChar ):Integer; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var pDB: pPseudoDB; sRoot: PChar; begin pDB := CreatePseudoDB(); sRoot := PseudoDB_LoadFromUSBRoot(pDB,PChar('K:\')); -> Zugriffsverletzung PseudoDB_Destroy(pDB); -> Auch Zugriffsverletzung end; |
Re: C++ DLL in Delphi einbinden
Zitat:
Zitat:
Zitat:
|
Re: C++ DLL in Delphi einbinden
rein logisch gesehen verwendest du die Funktionen ja richtig (mal mit ausnahme des ansi vs. unicode string problems), aber ohne die Details besagter funktionen zu kennen, kann man da schlecht urteilen.
|
Re: C++ DLL in Delphi einbinden
müssen die funktionen eventuell noch als stdcall deklariert werden?
|
Re: C++ DLL in Delphi einbinden
Die cpp Datei habe ich natürlich auch. Nur kann ich wie gesagt nicht viel damit anfangen
Der Rest steht oben
Code:
PseudoDB* CreatePsuedoDB()
{ return (PseudoDB*)new CPseudoDB; } int PseudoDB_LoadFromUSBRoot(PseudoDB* pDB,const wchar_t* sRoot) { CPseudoDB* pObj=(CPseudoDB*)pDB; return pObj->loadFromUSBRoot(sRoot) ? 1 : 0; } void PseudoDB_Destroy(PseudoDB* pDB) { CPseudoDB* pObj=(CPseudoDB*)pDB; delete pObj; } class CPseudoDB { public: CPseudoDB(); ~CPseudoDB(); bool loadFromUSBRoot(const wchar_t* sIPodRoot); bool loadFile(const wchar_t* sFilename); int newTrackID(); bool findIPods(); int getIPodCount(); const wchar_t* getUSBRoot(int index); Track* newTrack(); static void freeTrack(Track* pTrack); Playlist* newPlaylist(); static void freePlaylist(Playlist* pList); static void setString(gunichar2*& rpString,const gunichar2* sVal); static void itunesdb_convert_filename_fs2ipod (wchar_t* ipod_file); static void itunesdb_convert_filename_ipod2fs (wchar_t* ipod_file); static wchar_t *itunesdb_get_track_name_on_ipod (const wchar_t*path, Track *s); protected: void itunesdb_rename_files (const wchar_t*dirname); gboolean itunesdb_copy_track_to_ipod (const wchar_t*path, Track *track, const wchar_t*pcfile); gboolean itunesdb_cp (const wchar_t*from_file, const wchar_t*to_file); guint32 itunesdb_time_get_mac_time (void); Track *itunesdb_new_track (void); time_t itunesdb_time_mac_to_host (guint32 mactime); guint32 itunesdb_time_host_to_mac (time_t time); /* structure to hold the contents of one entry of the Play Count file */ typedef struct _playcount { guint32 playcount; guint32 time_played; gint32 rating; } playcount; gunichar2 * get_mhod (FILE *file, glong seek, gint32 *ml, gint32 *mty); glong get_pl(FILE *file, glong seek); glong get_mhit(FILE *file, glong seek); playcount *get_next_playcount (void); void reset_playcounts (void); void init_playcounts (const wchar_t*dirname); gboolean process_OTG_file (const wchar_t*filename, const wchar_t*plname); void read_OTG_playlists (const wchar_t*dirname); void mk_mhbd (FILE *file); void fix_mhbd (FILE *file, glong mhbd_seek, glong cur); void mk_mhsd (FILE *file, guint32 type); void fix_mhsd (FILE *file, glong mhsd_seek, glong cur); void mk_mhlt (FILE *file, guint32 track_num); void mk_mhit (FILE *file, Track *track); void fix_mhit (FILE *file, glong mhit_seek, glong cur, gint mhod_num); void mk_mhod (FILE *file, guint32 type, gunichar2 *string, guint32 fqid); void mk_mhlp (FILE *file, guint32 lists); void fix_mhlp (FILE *file, glong mhlp_seek, gint playlist_num); void mk_weired (FILE *file); void mk_mhyp (FILE *file, gunichar2 *listname, guint32 type, guint32 track_num); void fix_mhyp (FILE *file, glong mhyp_seek, glong cur); void mk_mhip (FILE *file, guint32 id); void write_mhsd_one(FILE *file); void write_playlist(FILE *file, Playlist *pl); void write_mhsd_two(FILE *file); gboolean write_it (FILE *file); gboolean it_add_track (Track *track); Playlist* it_add_playlist(Playlist *plitem); void it_add_trackid_to_playlist (Playlist* plitem, guint32 id); guint it_get_nr_of_tracks (void); Track *it_get_track_by_nr (guint32 n); guint32 it_get_nr_of_playlists (void); Playlist *it_get_playlist_by_nr (guint32 n); guint32 it_get_nr_of_tracks_in_playlist (Playlist *plitem); guint32 it_get_trackid_in_playlist_by_nr (Playlist *plitem, guint32 n); bool isIPodRoot(const wchar_t* sRoot); void clearIPodRoots(); GList *CPseudoDB::playcounts; guint32 *CPseudoDB::mpl_ids; guint32 CPseudoDB::mpl_length; std::vector<Track*> m_aTracks; std::vector<Playlist*> m_aPlaylists; std::vector<wchar_t*> m_aIPodRoots; int m_NextTrackID; }; |
Re: C++ DLL in Delphi einbinden
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:01 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