Seite 1 von 1

TCHAR mit QT verwenden

Verfasst: 12. November 2007 21:42
von tommy_gun
Hallo,

Ich versuche mit einer DLL auf das Datenbanksystem eines Visualisierungssystems zuzugreifen. Dazu habe ich die DLL und ein header-file bekommen. Wenn ich den header nicht include kann ich alles kompilerern und das Programm läuft. Ich kann die DLL sogar laden. Include ich den header beginnen die Probleme. Habe nun alles ausser den zwei funktionen PDBSConnect bzw. PDBSDisconnect auskommentiert. in PDBSConnect gibt es aber einige Probleme. Hier der Header:

#ifndef __pdbsdll_h
#define __pdbsdll_h 1 // prevent multiple #includes

/*
#define PDBS_OPENFILE 0x10 // Datei öffnen
#define PDBS_CLOSEFILE 0x11 // Datei schliessen
#define PDBS_ISOPENFILE 0x12 // Test, ob Datei bereits geöffnet
#define PDBS_APPEND 0x13 // Datensatz anhängen
#define PDBS_GETBULK 0x14 // Meherere Datensätze abfragen
#define PDBS_MOVE 0x15 // Datensatzzeiger auf X-Position verschieben
#define PDBS_MOVENEXT 0x16 // Nächster Datensatz lesen
#define PDBS_MOVEPREV 0x17 // Vorheriger Datensatz lesen
#define PDBS_SETFILTERDMS 0x18 // Filter für DMS-Namen setzen
#define PDBS_SETFILTERTEXT 0x19 // Filter für Text setzen
#define PDBS_CLEARFILTER 0x1A // Filter löschen
#define PDBS_MOVETIME 0x1B // Datensatz nach Zeitstempel lesen
*/

#ifndef PDBS_DLL
#ifdef _DEBUG
//#pragma comment (lib, "\\PROMOS13\\lib\\pdbsD.lib")
#else
//#pragma comment (lib, "\\PROMOS13\\lib\\pdbs.lib")
#endif
#endif

class CPLog;

// Funktionen mit TRD-Daten
int _stdcall PDBSConnect(TCHAR* pcname, CPLog* pLog = NULL, bool bLog = FALSE);
bool _stdcall PDBSDisconnect(int idx);

/*
HANDLE _stdcall PdbsConnect(TCHAR* pcname);
bool _stdcall PdbsDisconnect(HANDLE hPipe);
int _stdcall PdbsGetData(HANDLE hPipe, TCHAR* dmsname, time_t start, time_t end, int count, DBData* Data);
int _stdcall PdbsGetCount(HANDLE hPipe, TCHAR* dmsname, time_t start, time_t end);
bool _stdcall PdbsSetDir(HANDLE hPipe, TCHAR* dir);

bool _stdcall PdbsAppendTrd(HANDLE hPipe, TCHAR* DMSName, DBData* Data);

// Sollte nicht mehr gebraucht werden !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BOOL _stdcall PdbsGetLastData(HANDLE hPipe, TCHAR* DMSName, DBData* Data);

BOOL _stdcall PdbsSetPointCount(HANDLE hPipe, int Count);
int _stdcall PdbsGetPointCount(HANDLE hPipe);
TCHAR* _stdcall PdbsGetPointListFirst(HANDLE hPipe);
TCHAR* _stdcall PdbsGetPointListNext(HANDLE hPipe);


#define PDMSDATASIZE 256

// Funktionen mit 'normalen' Daten (Alarme, Protokolle usw).
int _stdcall PDBS_Open(HANDLE hPipe, TCHAR* Filename);
int _stdcall PDBS_Close(HANDLE hPipe, TCHAR* Filename);
int _stdcall PDBS_IsOpen(HANDLE hPipe, TCHAR* Filename);
int _stdcall PDBS_GetCount(HANDLE hPipe, TCHAR* Filename);
int _stdcall PDBS_GetTimeCount(HANDLE hPipe, TCHAR* Filename, time_t start, time_t end);

int _stdcall PDBS_Append(HANDLE hPipe, TCHAR* Filename, PDBSData* Data);
bool _stdcall PdbsAppendFromFile(HANDLE hPipePDBS, TCHAR* DMSName, int FileNr);
bool _stdcall PdbsMergePrt(HANDLE hPipePDBS);
bool _stdcall PdbsAppendFromPrtFile(HANDLE hPipePDBS, TCHAR* Protocolname, int FileNr);

int _stdcall PDBS_GetBulkData(HANDLE hPipe, TCHAR* Filename, int position, int count, PDBSData* Data);
DBData* _stdcall PDBSGetTrdData(int pdbsID, TCHAR* Filename, time_t start, time_t stop, int intervall,
int& Count, char type);
DBData* _stdcall PdbsGetTrdData(HANDLE hPipe, TCHAR* Filename, time_t start, time_t stop, int intervall,
int& Count, char type);
void _stdcall PdbsFreeTrdData(DBData* data);
int _stdcall PDBS_Move(HANDLE hPipe, TCHAR* Filename, int position, PDBSData* Data);
int _stdcall PDBS_MoveNext(HANDLE hPipe, TCHAR* Filename, PDBSData* Data);
int _stdcall PDBS_MovePrev(HANDLE hPipe, TCHAR* Filename, PDBSData* Data);
int _stdcall PDBS_SetFilterDMS(HANDLE hPipe, TCHAR* Filename, TCHAR* DMSName);
int _stdcall PDBS_SetFilterText(HANDLE hPipe, TCHAR* Filename, TCHAR* Text);
int _stdcall PDBS_ClearFilter(HANDLE hPipe, TCHAR* Filename);
int _stdcall PDBS_MoveTime(HANDLE hPipe, TCHAR* Filename, time_t zeit);

// Alarmdaten (aktuelle) nicht auf DISK
int _stdcall PDBS_GetAlarm(HANDLE hPipe, PDBSData* Data);
int _stdcall PDBS_PutAlarm(HANDLE hPipe, TCHAR* Filename, PDBSData* Data);
int _stdcall PDBS_FilterAlarm(HANDLE hPipe, Filtereinstellung* Data);

BOOL _stdcall PdbsRenameTrd(HANDLE hPipe, TCHAR* DMSName, TCHAR* DMSNameNew, TCHAR* path);
STTrd* _stdcall PdbsGetPath(HANDLE hPipe, TCHAR* TrdNameOld, TCHAR* TrdNameNew, int &Count);

void _stdcall PdbsFreeSTTrd(STTrd* data);
time_t _stdcall PDBSGetTime(int pdbsID, TCHAR* DMSName);
*/


#endif // __pdbsdll_h prevent multiple #includes

und die Fehlermeldungen des Compilers:

In file included from test_dll.cpp:6:
pdbsdll.h:35: warning: `__stdcall__' attribute only applies to function types
pdbsdll.h:35: error: `TCHAR' was not declared in this scope
pdbsdll.h:35: error: `pcname' was not declared in this scope
pdbsdll.h:35: error: expected primary-expression before '*' token
pdbsdll.h:35: error: `pLog' was not declared in this scope
pdbsdll.h:35: error: expected primary-expression before "bool"
pdbsdll.h:35: error: initializer expression list treated as compound expression
mingw32-make[1]: *** [debug\test_dll.o] Error 1
mingw32-make[1]: Leaving directory `D:/Thoemus_Stuff/Projekte/test_dll'
mingw32-make: *** [debug] Error 2

Kann mir jemand erklären was die Fehlermeldungen bedeuten und wie ich die Probleme am besten angehe?

Danke für die Hilfe

Gruss
tommy

Verfasst: 12. November 2007 22:54
von Christian81
1. benutze bitte die

Code: Alles auswählen

 - Tags!
2. das header-File ist unvollständig - es fehlt ein #include <windows.h>
3. WCHAR to QString -> [url=http://doc.trolltech.com/4.3/qstring.html#fromUtf16]QString::fromUtf16()[/url]
4. und falls TCHAR doch nur char ist wirst Du wohl selbst ne Funktion finden können :)