DDEClient structure
Verfasst: 10.04.2011 14:22
Ich habe hier eine DLL Datei, die eine Structure und eine Variable exportiert:
Wie bekomme ich zugriff auf diese Structure ?
Hier meine PB-Include:
Und ein Test-Programm dazu:
Hier die Debug Ausgabe:
Wie bekomme ich zugriff auf diese Structure ?
Code: Alles auswählen
// DDE data structure for access data received by DDE transaction
typedef struct {
// pointer to begin of dde data returned by DdeAccessData
BYTE* pData;
// length of dde data returned by DdeAccessData
DWORD dwLen;
// string pointer to dde data, if the data should accessed as string
char* pszData;
// ID of transaction, used to determine completion of asynchronous transaction
DWORD dwTransID;
// ID of transaction, returned by callback function with asynch. transaction
DWORD dwCbTransID;
// string for access type of data
char szAccType[6];
} DCDATAACCESS;
// maximal number of dde conversations
const WORD wCONVMAX = 20;
// pointer array to dde conversation variables
DDEVARS* DdeV[wCONVMAX];
// pointer array to dde data access variables
DCDATAACCESS* DDA[wCONVMAX];
#define DllExport extern "C" _declspec( dllexport )
//
// exported variables
//
// boolean used by DCLastError for appearance of error messages.
// false: Messages are shown in a system message box.
// true: Messages are passed to the calling program.
DllExport bool bDCErrorExport = false;
// pointer to an pointer array to dde data access variables
DllExport DCDATAACCESS* *DCDA = DDA;
Code: Alles auswählen
Global DDEClient_hDLL.i
; http://planet.plt-scheme.org/package-source/mato/ddeclient.plt/1/0/
;- Prototype
Prototype.l DCAbandonTransaction(wC.w, dwTransID.l)
Prototype.l DCAsynchTransactionCompleted(wC.w, dwTransID.l, bWait.l)
Prototype.l DCConnect(*pConvNo.i, szService.p-ascii, szTopic.p-ascii)
Prototype.l DCDA()
Prototype.l DCDisconnect(wConvNo.w)
Prototype.l DCFinalize()
Prototype.l DCFreeDdeMem(wConvNo.w)
Prototype.l DCInit()
Prototype.l DCLastError()
Prototype.l DCRequest(wC.w, szItem.p-ascii, szFormat.p-ascii, nTimeout.l)
Prototype.l DCRequestString(wC.w, szItem.p-ascii, nTimeout.l)
Prototype.l DCTransaction(wC.w, szType.p-ascii, szItem.p-ascii, szData.p-ascii, szFormat.p-ascii, nTimeout.l, szAccess.p-ascii)
Prototype.l DCUninit()
Prototype.l DCVersion()
Prototype.l bDCErrorExport()
Procedure DDEClient_CloseDLL()
If DDEClient_hDLL > 0
If IsLibrary(DDEClient_hDLL)
CloseLibrary(DDEClient_hDLL)
EndIf
DDEClient_hDLL=0
EndIf
EndProcedure
Procedure DDEClient_OpenDLL()
DDEClient_hDLL=OpenLibrary(#PB_Any, "DDEClient.dll")
If DDEClient_hDLL=0
ProcedureReturn #False
EndIf
Global DCAbandonTransaction.DCAbandonTransaction=GetFunction(DDEClient_hDLL,"DCAbandonTransaction")
Global DCAsynchTransactionCompleted.DCAsynchTransactionCompleted=GetFunction(DDEClient_hDLL,"DCAsynchTransactionCompleted")
Global DCConnect.DCConnect=GetFunction(DDEClient_hDLL,"DCConnect")
Global DCDA.DCDA=GetFunction(DDEClient_hDLL,"DCDA")
Global DCDisconnect.DCDisconnect=GetFunction(DDEClient_hDLL,"DCDisconnect")
Global DCFinalize.DCFinalize=GetFunction(DDEClient_hDLL,"DCFinalize")
Global DCFreeDdeMem.DCFreeDdeMem=GetFunction(DDEClient_hDLL,"DCFreeDdeMem")
Global DCInit.DCInit=GetFunction(DDEClient_hDLL,"DCInit")
Global DCLastError.DCLastError=GetFunction(DDEClient_hDLL,"DCLastError")
Global DCRequest.DCRequest=GetFunction(DDEClient_hDLL, "DCRequest")
Global DCRequestString.DCRequestString=GetFunction(DDEClient_hDLL,"DCRequestString")
Global DCTransaction.DCTransaction=GetFunction(DDEClient_hDLL,"DCTransaction")
Global DCUninit.DCUninit=GetFunction(DDEClient_hDLL,"DCUninit")
Global DCVersion.DCVersion=GetFunction(DDEClient_hDLL,"DCVersion")
Global bDCErrorExport.bDCErrorExport=GetFunction(DDEClient_hDLL,"bDCErrorExport")
ProcedureReturn #True
EndProcedure
Code: Alles auswählen
IncludeFile "DDEClient.pbi"
Structure DCDATAACCESS
pData.l
dwLen.l
pszData.l
dwTransID.l
dwCbTransID.l
szAccType.a[6]
EndStructure
Structure DCDATAACCESS_array
DDA.DCDATAACCESS[0]
EndStructure
Define wConvNo.w, szType.s, szData.s, szItem.s, szService.s, szTopic.s, szFormat.s, dwTimeout.l, szAccess.s, *DDA.DCDATAACCESS_array
szService = "DdeSrvr"
szTopic = "DdeTestTopic"
szType = "request"
szItem = "DdeTestItem"
szData = "Hallo Welt!"
szFormat = "CF_TEXT"
dwTimeout = 1000
szAccess = "string"
If DDEClient_OpenDLL()
Debug "DDEClient_OpenDLL"
Debug ""
Debug "DCVersion"
res = DCVersion()
Debug "res: " + Str(res)
If res
Debug PeekS(res, -1, #PB_Ascii)
EndIf
Debug ""
Debug "DCDA: " + Str(DCDA)
Debug "bDCErrorExport: " + Str(bDCErrorExport)
Debug ""
*DDA.DCDATAACCESS_array = DCDA
PokeL(bDCErrorExport, 1)
If DCInit()
If DCConnect(@wConvNo, szService, szTopic)
Debug "DCConnect - " + Str(wConvNo)
If DCTransaction(wConvNo, "poke", szItem, szData, szFormat, 1000, "string")
Debug "DCTransaction"
Else
res = DCLastError()
If res
Debug PeekS(res, -1, #PB_Ascii)
EndIf
EndIf
If DCDisconnect(wConvNo)
Debug "DCDisconnect"
EndIf
Debug ""
EndIf
If DCConnect(@wConvNo, szService, szTopic)
Debug "DCConnect - " + Str(wConvNo)
If DCTransaction(wConvNo, "request", szItem, szData, szFormat, 1000, "string")
Debug "DCTransaction"
Debug PeekS(*DDA\DDA[wConvNo]\pszData ,-1, #PB_Ascii)
Else
res = DCLastError()
If res
Debug PeekS(res, -1, #PB_Ascii)
EndIf
EndIf
If DCDisconnect(wConvNo)
Debug "DCDisconnect"
EndIf
Debug ""
EndIf
DCUninit()
EndIf
DCFinalize()
DDEClient_CloseDLL()
EndIf
End
Code: Alles auswählen
DDEClient_OpenDLL
DCVersion
res: 268488872
DDEClient.dll, version 0.03, copyright Robert Matovinovic, robert.matovinovic@web.de
DCDA: 268488960
bDCErrorExport: 268491500
DCConnect - 0
DCTransaction
DCDisconnect
DCConnect - 0
DCTransaction
B?
DCDisconnect