Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a C++ DLL libarary (not COM) that I want to use in
VBA. Is it possible to use this library in VBA. If so, how? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't think it matters terribly what language a DLL was created in. As
far as I know you need to know what functions a DLL exports, what parameters it expects, what it returns and then you need to "declare" these things. Here's an example of using a Windows DLL (advapi32.dll): Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long Sub ShowUserName() MsgBox UserName End Sub Function UserName() As String Dim Buffer As String * 256 Dim BuffLen As Long BuffLen = 256 If GetUserName(Buffer, BuffLen) Then _ UserName = Left(Buffer, BuffLen - 1) End Function -- Jim Rech Excel MVP wrote in message ... |I have a C++ DLL libarary (not COM) that I want to use in | VBA. Is it possible to use this library in VBA. If so, | how? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Its worth noting that the C++ DLL function(s) must have been
compiled with the __stdcall option. Otherwise, you can't call them. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jim Rech" wrote in message ... I don't think it matters terribly what language a DLL was created in. As far as I know you need to know what functions a DLL exports, what parameters it expects, what it returns and then you need to "declare" these things. Here's an example of using a Windows DLL (advapi32.dll): Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long Sub ShowUserName() MsgBox UserName End Sub Function UserName() As String Dim Buffer As String * 256 Dim BuffLen As Long BuffLen = 256 If GetUserName(Buffer, BuffLen) Then _ UserName = Left(Buffer, BuffLen - 1) End Function -- Jim Rech Excel MVP wrote in message ... |I have a C++ DLL libarary (not COM) that I want to use in | VBA. Is it possible to use this library in VBA. If so, | how? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help with Object Library | Setting up and Configuration of Excel | |||
Reference Library - Missing Library in a lower version. | Excel Programming | |||
Add library in vba | Excel Programming | |||
Use the .NET Library in VBA? | Excel Programming | |||
Library references | Excel Programming |