How to use external dll function

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
Hi

A GlobalVariable.dll as been created to exchange information between a trading software and the external word.

Function like GVSetString is available:
GVSetString( NewGlobalString, "This string will be strore in the NewGlobalString variable")

What is the process to get access to an external dll.
The file is :C\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll

Again any help appreciated because I'm :confused:

Martin
 
Rorya, Indeed, I had an error in the addressing. The file was on to places on the disk

Now, my new error message is translated by:

Error 49: DLL calling convention erroneus

Code:
Public DLLString  As String
Public Val As Integer

Option Explicit



Declare Function GV_GetInteger Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" (ByVal Val As Integer)
Declare Function GV_GetString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" (ByVal Val As Integer)
'


Sub UseGlobalVariable()
Dim Price As Double
Dim string2 As String
Dim va
Price = Price + 1

Price = GV_GetInteger(Val)
string2 = GV_GetString(3)
End Sub
Martin

Also,notice that in your declaration, you are not designating a Function return. I see your expecting a string so I suspect the API should return a Long pointer to the string.

Maybe something along these lines :
Declare Function GV_GetString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" (ByVal Val As Integer)As Long

If , after adding the above function return you don't get the calling convetion error anymore then the next step is to extract the actual string from its returned pointer.
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Also,notice that in your declaration, you are not designating a Function return. I see your expecting a string so I suspect the API should return a Long pointer to the string.

Maybe something along these lines :
Declare Function GV_GetString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" (ByVal Val As Integer)As Long

If , after adding the above function return you don't get the calling convetion error anymore then the next step is to extract the actual string from its returned pointer.

Hi Jaafar Tripak

I will look at your suggestion.

Wow, this dll calling, addressing confuse me a lot. I never work with that before. I will need to read more about it because honestly I don't understand what I'm doing and what i should look for.

So basically, I should at least understand a bit on the matter before asking question because more questions confuse me more. :)

Martin
 
Upvote 0
Martin .

Try this and tell us if you get an error and if so which error .

Code:
Public DLLString  As String
Public Val As Integer

Option Explicit



Declare Function GV_GetString Lib _
"C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal Val As Integer) As Long
'


Sub UseGlobalVariable()
Dim Price As Double
Dim string2 As String
Dim va
Price = Price + 1

string2 = GV_GetString(3)
End Sub
 
Upvote 0
Also try like the above but with this declaration :

Code:
Declare Function GV_GetString Lib _
"C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal Val [B][COLOR=Red]As Long[/COLOR][/B]) As Long
 
Upvote 0
A quick Google suggests:
Code:
Private Declare Function GV_GetInteger Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" (ByVal intElementLoc As Long) As Long
for the first one.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top