Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Using C++ Dll library

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Using C++ Dll library

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Using C++ Dll library

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Object Library Ayo Setting up and Configuration of Excel 1 November 6th 09 08:04 PM
Reference Library - Missing Library in a lower version. luvgreen Excel Programming 1 October 7th 04 02:08 AM
Add library in vba JonoB[_3_] Excel Programming 0 April 23rd 04 01:04 PM
Use the .NET Library in VBA? Thomas Wieser Excel Programming 1 April 14th 04 02:07 PM
Library references Amanda[_5_] Excel Programming 1 January 6th 04 06:40 PM


All times are GMT +1. The time now is 03:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"