HX_OpenDevice
打开设备,要对设备进行控制,必须先打开设备。int HX_OpenDevice (
HANDLE* phDev,
int iIndex
);
参数
phDev 
设备句柄指针,用来保存成功打开设备后返回的设备句柄。该设备句柄是WebViews公司内部定义的,不是标准的Windows句柄,因此不能使用Windows有关句柄操作的函数( 如CloseHandle() )对该句柄进行操作。
iIndex
HVC400设备编号,设备编号从0开始;若HX_GetDeviceCount()返回n,则有效的设备编号为0~n-1。
返回值
函数可能返回以下返回值: 

打开设备成功,设备句柄保存在phDev指针里。 
其他 
打开设备失败。
备注
同一个设备一旦被打开,就不能被再次打开,直到该设备被关闭为止。打开设备比较慢,因此建议不要频繁打开关闭设备。
我是这样做的:
定义function HX_OpenDevice (phDev:thandle;iIndex:integer):integer;stdcall;external 'SDK.dll';
procedure TForm1.BitBtn1Click(Sender: TObject);
var
  i:integer;
  lhnda:thandle;
begin
   i:=HX_OpenDevice(phdev,0);
end;返回如下错误:
[DCC Warning] unitmail.pas(38): W1036 Variable 'lhnda' might not have been initialized
程序不能运行,请问怎么解决,谢谢各位。

解决方案 »

  1.   

    局部变量要初始化,初始化lhnda为nil试试
      

  2.   

    C中的Hande是个指针,应该要改变值的,所以你这样定义试试
    function HX_OpenDevice (var phDev:thandle;iIndex:integer):integer;stdcall;external 'SDK.dll';
      

  3.   

    function HX_OpenDevice (phDev:Pointer;iIndex:integer):integer;stdcall;external 'SDK.dll';//如果定义的调用约定是__stdcall
    顺便和楼主说下,警告不会停止编译,不能运行该是编译错误
    附加一句,看这中定义,phDev对应的实参也就是你程序写的lhnda该给其初始化;
    该没问题的,楼主去测试下
      

  4.   

    function HX_OpenDevice (var phDev:thandle;iIndex:integer):integer;cdcel;external 'SDK.dll';换成 cdcel 试下,int HX_OpenDevice (
    HANDLE* phDev,
    int iIndex
    );
    没见有stdcall约定