RE: DllCall with SharedVar application

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rc76
Posts: 147
Joined: 07 Nov 2020, 01:45

RE: DllCall with SharedVar application

17 Apr 2024, 04:41

[Summary]
I am trying to use DllCall() with the SharedVar application, although I did get some results back, however the results are not accurate, for example:

svRealmCount
Expected Result: 1
Actual Result: -1

svVersion
Expected Result: 1.2.0.310
Actual Result: 491035856

Why is that?


[Background]
The SharedVar is an application used to store real-time data across trading platforms. The trading platform can use DLL to get/store data.
https://fx1.net/sharedvar.php


You see 4 different .dll files:
SharedVar-a32.dll : ANSI 32bit DLL
SharedVar-a64.dll : ANSI 64bit DLL
SharedVar-w32.dll : UNICODE 32bit DLL
SharedVar-w64.dll : UNICODE 64bit DLL

I used the “SharedVar-a64.dll” to test it, however I also tried “SharedVar-w64.dll”. Both return wrong results.

[My Test Script]
Please find below my test script:

Code: Select all

; ------------------------------------------------------------------------------

#SingleInstance, Force ; Force AHK to only run this script once (one at a time)

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability

SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory

DetectHiddenWindows, On

; ------------------------------------------------------------------------------
; Main

Get_Data_SV()

Return

; ------------------------------------------------------------------------------

Get_Data_SV(){
  ; SharedVar-a32.dll : ANSI  32bit DLL
  ; SharedVar-a64.dll   : ANSI  64bit DLL
  ; SharedVar-w32.dll   :   UNICODE 32bit DLL
  ; SharedVar-w64.dll : UNICODE 64bit DLL
  ; If you have MultiCharts 64bit, you should use ANSI 64bit


  ; Result := DllCall("C:\Program Files\TS Support\MultiCharts64\SharedVar-a64.dll\svRealmName", "Str" "ea1")
  ; Result := DllCall("SharedVar-a64.dll\svRealmName", "Str" "ea1")
  ; Result := DllCall("SharedVar-w64.dll\svRealmName", "Str" "ea1")

  ; Result := DllCall("SharedVar-w64.dll\svRealmCount")
  ; Result := DllCall("SharedVar-a64.dll\svRealmCount")
  Result := DllCall("C:\Program Files\TS Support\MultiCharts64\SharedVar-a64.dll\svRealmCount")
  msgbox, "svRealmCount: " %Result%
  ; Expected Result: 1
  ; Actual Result: -1

  ; Result := DllCall("C:\Program Files\TS Support\MultiCharts64\SharedVar-a64.dll\svVersion", "Cdecl AStr")
  ; Result := DllCall("C:\Program Files\TS Support\MultiCharts64\SharedVar-a64.dll\svVersion")
  Result := DllCall("SharedVar-a32.dll\svVersion")
  msgbox, "svVersion-32: " %Result%

  Result := DllCall("SharedVar-a64.dll\svVersion")
  msgbox, "svVersion-64: " %Result%
  ; Expected Result: 1.2.0.310
  ; Actual Result: 491035856



  Result := DllCall("C:\Program Files\TS Support\MultiCharts64\SharedVar-a64.dll\svRealmName", "Int64", 2640)
  msgbox, "svRealmName: " %Result%

  Result := DllCall("C:\Program Files\TS Support\MultiCharts64\SharedVar-a64.dll\svServerRunning")
  msgbox, "svServerRunning: " %Result%
}



rc76
Posts: 147
Joined: 07 Nov 2020, 01:45

Re: RE: DllCall with SharedVar application

23 Apr 2024, 17:28

Dear @mikeyww , any chance you may have some suggestions for this question?

Thank you so much @mikeyww!
User avatar
mikeyww
Posts: 27011
Joined: 09 Sep 2014, 18:38

Re: RE: DllCall with SharedVar application

23 Apr 2024, 17:52

Not my area! Others here may know.
Descolada
Posts: 1144
Joined: 23 Dec 2021, 02:30

Re: RE: DllCall with SharedVar application

24 Apr 2024, 10:55

DllCall's default return type is a 32-bit integer, but looking at the expected version number format it looks like a string. Try specifying "str" as the return type (or wstr/astr).
rc76
Posts: 147
Joined: 07 Nov 2020, 01:45

Re: RE: DllCall with SharedVar application

24 Apr 2024, 21:55

Thank you so much @mikeyww, @Descolada

A quick question about defining the return type for DLLCall().

If I want to define a return type of AStr, do I code like the following?

Code: Select all

Result := DllCall("SharedVar-a64.dll\svVersion", "Cdecl AStr")
msgbox, "svVersion-64: " %Result%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: FanaticGuru, Google [Bot] and 237 guests