LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Win32 VB DLLs in Labview 8.0

Hi All,
 
I have a Win32 VB dll. i need to call this dll in Labview8.0. For this directly i am using 'Call Library function node' with the calling convention of 'stdcall(WINAPI)'.
 
please tell me will it support? otherwise wether i need to use activex controls...if so how to use them...
 
thanks,
Bannu.
0 Kudos
Message 1 of 12
(4,881 Views)

this is the continution of above question. i can able to view all the functions in "function name" of 'Call Library function node' which are available in my dll and "DllCanUnloadNow, DllGetClassObject, DllRegisterServer, and DllUnregisterServer" functions too.

will it work this call library function node for my VB win32 dll. but while listing the function its not displaying the parameters(arguments) of functions.for this what i need to do ?

0 Kudos
Message 2 of 12
(4,881 Views)
Hi,

To learn more on how to use external code with LabVIEW, I suggest you look at this tutorial.  Here is a mini-tutorial on how to use call library function nodes (LV 7).  When you click a function and the prototype is void, you can go to the Parameters Tab and add certain parameters to the dll to conform to the dll function standards. 

I hope this helps,

Regards,

Nadim
Applications Engineering
National Instruments
0 Kudos
Message 3 of 12
(4,875 Views)

Hi,

 

Thanks for reply. I already had gone through those documents. Actually, I have a VB dll. A function in VB dll requires the string as an input parameter. The example code of that VB function looks like this:

 

Public Function mystring(ByRef str As String) As String

Dim str1 As String

str = StrConv(str, vbUnicode)

str = str + "world"

mystring = StrConv(str1, vbFromUnicode)

mystring = str

End Function

 

I called this function in Labview by using “Call Library Function Node” with the parameters as follows:

 

Function name: mystring

Calling Convention: stdcall (WINAPI)

Parameter:

  1. return type    Type: String    String Format: Pascal String Pointer

  2. arg1             Type: String    String Format: Pascal String Pointer

I gave an input string as “Hello”. When I am trying to run the VI, I am getting an exception that “An exception occurred within the external code called by a call library function node. This might have corrupted LabVIEW’s memory. Save any work to a new location and restart LabViewi.”

Moreover, the same error I am getting for passing charecter array too.

 

VB code:

 

Public Function mychar(var() As Byte) As Long

newchar = var(0)

End Function

 

I called this function in Labview by using “Call Library Function Node” with the parameters as follows:

 

Function name: mychar

Calling Convention: stdcall (WINAPI)

Parameter:

     1. return type       Type: Numeric        Data Type: Signed 32-bit Integer

     2. arg1                Type: Array            Data Type: Unsigned 8-bit Integer. Dimension: 1       Array Format: Array Data Pointer

 

 

Can you please tell me why I am getting this error and how to recover this?

 

Thanks,

Bannu.

0 Kudos
Message 4 of 12
(4,861 Views)
Hi Bannu,

What version of VB do you have? 

If you are using Visual Studio 2002, 03, or 05, you may want to use the .NET constructor instead of the call function library node.  You would then need to call an .NET invoke node and close the reference at the end. 

I would also test out your function in VB before implementing it in LabVIEW.  One thing you may want to check is the "ByRef" parameter.  You may want to change that to a ByVal parameter and not use any pointers. 

Let me know how it goes and I hope this helps,

Regards,

Nadim
Applications Engineering
National Instruments
0 Kudos
Message 5 of 12
(4,844 Views)


@bannu wrote:

this is the continution of above question. i can able to view all the functions in "function name" of 'Call Library function node' which are available in my dll and "DllCanUnloadNow, DllGetClassObject, DllRegisterServer, and DllUnregisterServer" functions too.

will it work this call library function node for my VB win32 dll. but while listing the function its not displaying the parameters(arguments) of functions.for this what i need to do ?



The functions you list would indicate that the DLL is really an ActiveX component. These are the exported functions that regsrv32 and the OS use to manage OLE (ActiveX) DLLs and it would probably make sense since I believe that newer Visual Basic versions tend to favour ActiveX over normal shared library call interfaces.

If this is the case then I would expect you have to use the ActiveX functions in LabVIEW to access your library rather than the Call Library Node.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 12
(4,833 Views)

Thank you for your reply. ya now am using ActiveX Vis. My dll is having somany functions. in dll these functions are defined as classes.

for example my dll having functions like init(), close();

i called the function init(), its working fine. its initialising my required software.

but when i tried to call(execute) the second function, its giving the error that, "Error -2146827864 occurred at Exception occured in Project1: Object required in close test.vi" . can you please tell me y m getting this type of error. and how can i rectify this.?

 

thanks,

bannu.

0 Kudos
Message 7 of 12
(4,818 Views)


@bannu wrote:

Thank you for your reply. ya now am using ActiveX Vis. My dll is having somany functions. in dll these functions are defined as classes.

for example my dll having functions like init(), close();

i called the function init(), its working fine. its initialising my required software.

but when i tried to call(execute) the second function, its giving the error that, "Error -2146827864 occurred at Exception occured in Project1: Object required in close test.vi" . can you please tell me y m getting this type of error. and how can i rectify this.?

 

thanks,

bannu.



Sorry! I can't help you with this really. Would seem like your ActiveX library is expecting something that does not come over correctly from LabVIEW somehow and then your DLL crashes. To debug this one would need the Visual Basic project, the eventual external libraries your DLL depends on and the LabVIEW VIs, but I have pledged years ago to never touch Visual Basic if I can avoid it in any way.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 8 of 12
(4,808 Views)

Thank you for response. ya i got the solution. i need to create a single class with functions. by using class object i need to call the function required.

thanks,

bannu.

0 Kudos
Message 9 of 12
(4,793 Views)

Bannu wrote:

Thank you for response. ya i got the solution. i need to create a single class with functions. by using class object i need to call the function required.


I am having the same problem. Could you expand on your solution? Did the changes occur in VB or LabView?

Thank you,

Tessa

0 Kudos
Message 10 of 12
(4,417 Views)