ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Load Dll (https://www.excelbanter.com/excel-programming/383660-load-dll.html)

Lisandro Oliveira

Load Dll
 
Does anyone know how can I load a dll from vba (excel)

Path: "C:\apps_pub\tn327080\ehllap32.dll

I need to execute this function: WaitPSSync()

Tks,
Lisandro Oliveira.



joel

Load Dll
 
What do you mean by load. Do you mean you want to open and read the file.
Or do you mean that you want to copy ehllap32.dll to the path that you show.

Does WaitPSSync() require that the dll be in the directtory shown?

"Lisandro Oliveira" wrote:

Does anyone know how can I load a dll from vba (excel)

Path: "C:\apps_pub\tn327080\ehllap32.dll

I need to execute this function: WaitPSSync()

Tks,
Lisandro Oliveira.



merjet

Load Dll
 
You need to register the DLL if that hasn't been done.
Start | Run regsvr32 "C:\apps_pub\tn327080\ehllap32.dll"
In the VBA Editor, check it using menu Tools | References.
Declare and set an object of a public Class in the DLL, e.g.:
Dim myObj As MyDLL.Class1
Set myObj = New MyDLL.Class1
Call the function (with any required arguments):
y = myObj.Function1(x)

When done: Set myObj = Nothing

Hth,
Merjet



Lisandro Oliveira

Load Dll
 
Hi Joel,
I need to read this dll and execute the WaitPSSync() function.
This is the address "C:\apps_pub\tn327080\ehllap32.dll" where it is in my
machine.

regards,
Lisandro

"Joel" wrote:

What do you mean by load. Do you mean you want to open and read the file.
Or do you mean that you want to copy ehllap32.dll to the path that you show.

Does WaitPSSync() require that the dll be in the directtory shown?

"Lisandro Oliveira" wrote:

Does anyone know how can I load a dll from vba (excel)

Path: "C:\apps_pub\tn327080\ehllap32.dll

I need to execute this function: WaitPSSync()

Tks,
Lisandro Oliveira.



Andy Smith

Load Dll
 
The DLL is loaded when the Excel file is opened, provided there's a
declaration for the WaitPSSync function in your code, and the DLL is in
either System32 or the same folder as the Excel file, in which case it's best
to change the current directory to that folder by putting "ChDir
ThisWorkbook.Path" in ThisWorkbook/Workbook_Open.

You have to be careful and know the language/compiler with which the DLL was
written, because the Declare statement in the VBA code has to have all
parameters and the return type identical with respect to both type and
calling convention (reference/value). In particular, C/C++'s default
convention is by value, but VBA's is by reference (pointer). Worse yet,
string parameters, which are pointers, should nevertheless be declared by
value, because the parameter is actually a pointer.

For example:
Public Declare Function WaitPSSync Lib "ehllap32" As Long
assumes it takes no parameters and returns a signed long

but:
Public Declare Sub WaitPSSync Lib "ehllap32" (ByVal LongParm As Long)
takes a signed long and returns nothing.

--

--Andy Smith



"Lisandro Oliveira" wrote:

Does anyone know how can I load a dll from vba (excel)

Path: "C:\apps_pub\tn327080\ehllap32.dll

I need to execute this function: WaitPSSync()

Tks,
Lisandro Oliveira.



Lisandro Oliveira

Load Dll
 
Thanks for all!!!!!

I will try to do it.

regards,
Lisanro

"Andy Smith" wrote:

The DLL is loaded when the Excel file is opened, provided there's a
declaration for the WaitPSSync function in your code, and the DLL is in
either System32 or the same folder as the Excel file, in which case it's best
to change the current directory to that folder by putting "ChDir
ThisWorkbook.Path" in ThisWorkbook/Workbook_Open.

You have to be careful and know the language/compiler with which the DLL was
written, because the Declare statement in the VBA code has to have all
parameters and the return type identical with respect to both type and
calling convention (reference/value). In particular, C/C++'s default
convention is by value, but VBA's is by reference (pointer). Worse yet,
string parameters, which are pointers, should nevertheless be declared by
value, because the parameter is actually a pointer.

For example:
Public Declare Function WaitPSSync Lib "ehllap32" As Long
assumes it takes no parameters and returns a signed long

but:
Public Declare Sub WaitPSSync Lib "ehllap32" (ByVal LongParm As Long)
takes a signed long and returns nothing.

--

--Andy Smith



"Lisandro Oliveira" wrote:

Does anyone know how can I load a dll from vba (excel)

Path: "C:\apps_pub\tn327080\ehllap32.dll

I need to execute this function: WaitPSSync()

Tks,
Lisandro Oliveira.




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com