有關DLL的調用;急!急!急! (100分)

  • 主题发起人 主题发起人 dastone
  • 开始时间 开始时间
D

dastone

Unregistered / Unconfirmed
GUEST, unregistred user!
在C中的'PDFENC32.DLL'的定義如下:<br>typedef struct s_pdfobject {<br>&nbsp; &nbsp;uint16 ioType; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Input/Output */<br>&nbsp; &nbsp;uint16 ioDirection; &nbsp; &nbsp; &nbsp; &nbsp;/* File/Callback/Memory */<br>&nbsp; &nbsp;PDFSIZET nLen; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* (Bytes to encode)/(Bytes written) */<br><br>&nbsp; &nbsp;union {<br>&nbsp; &nbsp; &nbsp; LPMEMBUF lpMemBuffer;<br>&nbsp; &nbsp; &nbsp; struct {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LPFNPDFIO lpfnCallback;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LPVOID lpAppArg;<br>&nbsp; &nbsp; &nbsp; } func;<br>&nbsp; &nbsp; &nbsp; struct {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FILEHANDLE hFile;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FILEPOS nInitPos;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Bool fMustClose;<br>&nbsp; &nbsp; &nbsp; } file;<br>&nbsp; &nbsp; &nbsp; struct {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LPMEMBUF lpMem; &nbsp; &nbsp; &nbsp;/* For CF_TEXT clipboard input */<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint16 fmtOutput; &nbsp; &nbsp;/* API definition for output format */<br>&nbsp; &nbsp; &nbsp; } clip;<br>&nbsp; &nbsp;} access;<br>&nbsp; &nbsp;Bool fIsHuge;<br>&nbsp; &nbsp;LPVOID lpState; &nbsp; &nbsp; &nbsp; &nbsp; /* internal state information/buffer */<br><br>} PDFObject;<br>typedef PDFObject FAR *LPPDFObject;<br><br>Bool PDFAPI MakeMemoryObject( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpBase );<br><br>在delphi中的調用定義如下:<br>Type<br>&nbsp; pTPDFObj=^TPDFOBJ ;<br><br>&nbsp; TPDFOBJ =record<br>&nbsp; &nbsp;ioType: Integer; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Input/Output<br>&nbsp; &nbsp;ioDirection: Integer; &nbsp; &nbsp; &nbsp; // File/Callback/Memory<br>&nbsp; &nbsp;nLen:Double; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // (Bytes to encode)/(Bytes written)<br><br>&nbsp; &nbsp;// Type specific information storage<br>&nbsp; &nbsp;dummy1 :Double;<br>&nbsp; &nbsp;dummy2 :Double;<br>&nbsp; &nbsp;dummy3 :Double;<br>&nbsp; &nbsp;dummy4 :Double;<br>&nbsp; &nbsp;dummy5 :Double;<br><br>&nbsp; &nbsp;dummy6 :Double;<br>&nbsp; &nbsp;dummy7 :Double;<br>end;<br><br>Function MakeMemoryObject(lpObj : pTPDFObj; var ioDirection : Integer; lpBase : Variant) : Integer;stdcall;external 'PDFENC32.DLL' name 'MakeMemoryObject';<br><br>調用:<br>function TForm1.EncodeSourceFile:Boolean;<br>var<br>&nbsp; nErrCode:Integer;<br>&nbsp; ObjInput:pTPDFObj;<br>begin<br>&nbsp; Result:=True;<br><br>&nbsp; &nbsp; ObjInput:=new(pTPDFObj);<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; nErrCode:=MakeFileNameObject(ObjInput,PDFINPUT,pChar &nbsp; &nbsp;(SourceFileName));<br>&nbsp; &nbsp; &nbsp; if nErrCode&lt;0 then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ShowMessage('Encode Error!');<br>&nbsp; &nbsp; &nbsp; &nbsp; Result:=False ;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; dispose(ObjInput);<br>&nbsp; &nbsp; end; &nbsp;<br>&nbsp; end;<br>end;<br><br>可是無論怎樣調用都出錯,不知道我的定義對不對,有那位大俠幫忙,不勝感謝!<br>
 
建议你在C++中调用一下,如果正常的话再在Delphi中调用一次。<br>
 
很可能还是你的定义有问题<br>给你转换一下<br><br>s_pdfobject = packed record<br>&nbsp; ioType: uint16; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Input/Output<br>&nbsp; ioDirection: uint16; &nbsp; &nbsp; &nbsp; &nbsp;// File/Callback/Memory<br>&nbsp; nLen: PDFSIZET; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // (Bytes to encode)/(Bytes written)<br><br>&nbsp; access: packed record<br>&nbsp; &nbsp; case Integer of<br>&nbsp; &nbsp; &nbsp; 0: (<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpMemBuffer: LPMEMBUF;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br>&nbsp; &nbsp; &nbsp; 1: (<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;func: packed record<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpfnCallback: LPFNPDFIO;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpAppArg: LPVOID;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br>&nbsp; &nbsp; &nbsp; 2: (<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;file: packed record<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hFile: FILEHANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nInitPos: FILEPOS;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fMustClose: Bool;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br>&nbsp; &nbsp; &nbsp; 3: (<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clip: packed record<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpMem: LPMEMBUF; &nbsp; &nbsp; &nbsp;// For CF_TEXT clipboard input<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fmtOutput: uint16; &nbsp; &nbsp;// API definition for output format<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br><br>&nbsp; fIsHuge: Bool;<br>&nbsp; lpState: LPVOID; &nbsp; &nbsp; &nbsp; &nbsp; // internal state information/buffer<br>end;<br><br>PDFObject &nbsp; = s_pdfobject;<br>LPPDFObject = ^PDFObject;<br><br><br><br>
 
后退
顶部