sFileName和lHandle都有问题,给你个个例子,参考一下:<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> //buffer: pchar;<br> data, result: array[0..512]of char;<br> h : HInst;<br> fn, fn2 : function (lpBuffer: PChar; uSize: UINT; Result: PChar): UINT; stdcall;<br> pn: procedure;stdcall;<br> //fs:LPCSTR;<br> c_len, d_len, i: integer;<br> s, s2: string;<br>begin<br><br> h:=LoadLibrary('code_dll.dll');<br> if h=0 then<br> begin<br> showMessage('load library error!');<br> exit;<br> end;<br> @fn := GetProcAddress(h,Pchar('golay_code'));<br> @fn2 := GetProcAddress(h,Pchar('golay_decode'));<br> @pn := GetProcAddress(h,Pchar('generate_golay_table'));<br> if (@fn=nil)or(@pn=nil) then<br> begin<br> showMessage('get proc address error!');<br> freelibrary(h);<br> exit;<br> end;<br><br> data := '12345';<br> //getmem(buffer,512);<br> pn;<br> c_len := fn(data,5,result);<br> d_len := fn2(result,c_len,data);<br><br> s := '';<br> for i:=0 to c_len-1 do<br> s := s+ format('%x/',[ord(result)]);<br> //caption := s;<br><br> s2 := '';<br> for i:=0 to d_len-1 do<br> s2 := s2+ format('%x/',[ord(data)]);<br> ShowMessage('golay_code:'+s+#13+'golay_decode:'+s2);<br><br> freelibrary(h);<br><br>end;<br>