我现在有一个dll(LocateAndRecognise.dll),先用regsvr32注册后,在vb中引用该dll,用vb的对象浏览器可以查看到其中的函数如下:
Class HeadsunRecognise
{
Function GetPixelArray(PixelArray As Byte, Charcount As Long) As long
Function LocateAndRecognise(sCarBoard(0 To 9) As String, nCarBoardColor(0 To 9) As Long, nCount As Long) As Long
Function ReLoadOcrdb() As long
Function SetLocateParamFile(sParamFileName As String) As long
Function SetReconisePicture(pBuf As Byte) As long
Function SetReconisePictureFileName(sBmpFileName As String) As Long
}
我在vb中按下面方式引用:
Dim hr As New HeadsunRecognise    Dim carbard As String
    Dim carbardcolor As Long
    Dim count As Long
    Dim i, j, k As Integer
    Dim pBuf(663552) As Byte    If Not IsNull(pBuf) Then
        count = hr.LocateAndRecognise(carbard, carbardcolor, 1)
        If count = 0 Then
            Me.Text1.Text = "No"
        Else
            Me.Text1.Text = carbard
        End If
    End If
运行时,确有如下错误: 
Compile Error:Function or interface ed as restricted,or the function uses an Automation type not supported in Visual Basic.
我本来想用申明的方式来使用该dll中的函数,可是没有函数的原型说明.
另外该dll提供了一个vc的使用说明如下:
 1:把LocateAndRecognise.dll(包括Param ,Ocrdb)与调用得程序放在同一个目录下;
2:在程序的stdAfx.h文件加入:
#import "LocateAndRecognise.dll" no_namespace named_guids
3:在调用识别地方的头文件里面声明: IHeadsunRecognisePtr m_pRecognise;
4:在调用识别地方的cpp文件里面的构造函数里面:
m_pRecognise.CreateInstance(__uuidof(HeadsunRecognise));
5:在析构函数里面释放:
m_pRecognise.Release();
6:调用识别如下:
void CStatAnalyzeView::OnRecognise() 
{
BSTR carbard;  //车牌
int carbardcolor;//车牌颜色代号
int i,j,k;
CDC *pDC=GetDC();
BYTE pBuf[768*288*3];//图片数据块(768×288的图片) 
if(pBuf!=NULL)
{
if(!m_pHeadsunRecognise->SetReconisePicture(pBuf))//设置识别缓冲区
{
return;
}
CString str="";
int count=m_pHeadsunRecognise->LocateAndRecognise(&carbard,&carbardcolor,1);//调用识别主调函数,返回值大于0有车牌,否则无车牌
if(count==0)//没有车牌
{
m_RecogResult="";
CString temp=carbard;
CStatic *PlateNum=(CStatic *)GetDlgItem(IDC_sPlateNum);
PlateNum->SetWindowText("无车牌");
CStatic *PlateColor=(CStatic *)GetDlgItem(IDC_sPlateColor);
PlateColor->SetWindowText("");
}
else
{
CString temp=carbard;
str.Format("车牌:%s\n车牌颜色:%d",temp,carbardcolor);
CStatic *PlateNum=(CStatic *)GetDlgItem(IDC_sPlateNum);
PlateNum->SetWindowText(temp);
CStatic *PlateColor=(CStatic *)GetDlgItem(IDC_sPlateColor);
switch(carbardcolor)//车牌颜色,0:黑色;1,2:白色;3:黄色;4:蓝色
{
case 0:
PlateColor->SetWindowText("黑色");
break;
case 1:
case 2:
PlateColor->SetWindowText("白色");
break;
case 3:
PlateColor->SetWindowText("黄色");
break;
case 4:
PlateColor->SetWindowText("蓝色");
break;
}
}
}
ReleaseDC(pDC);
}