Declaration of custom DLL inside SCADA BASIC, inside Virtual Machine

8 Posts
3 Users
0 Likes
35 Views
KASI
 KASI
(@k-simanjalamarcinfo-com)
Posts: 134
Estimable Member
Topic starter
 

Hello,

I have a issue report from user, he was creating a custom DLL and trying to declare it in PcVue using SCADA BASIC. The DLL was placed in PcVue Bin Folder.

The problem is, I tested his project on my laptop and it works fine, and user tried on his workstation, and it works too but failed to be declared inside VM environment.

I put here the code that was done to declare the dll and call the dll function.

Declare Function GetCoordinates LIB "DLL1" ALIAS "GetCoordinates" () As Str;'Private 
Declare Function GetCoordinatesX LIB "DLL1" ALIAS "GetCoordinatesX" () As long;'Private 
Declare Function GetCoordinatesY LIB "DLL1" ALIAS "GetCoordinatesY" () As long;'Private 

Sub testSetPos()
	Dim position As Str;
	Dim positionx As long;
	Dim positiony As long;
	
	Print("At test set pos");
	Print("Get position as 40X 40Y  :  ");
	
	position = GetCoordinates();
	positionx = GetCoordinatesX();
	positiony = GetCoordinatesY();
	
	Print("REeturn value : ", position);
	Print("GetCoordinatesY value : ", positionx);
	Print("GetCoordinatesX value : ", positiony);

End Sub

And here is the error that is shown on event viewer when run from VM.

2021/02/25,17:30:21.270,6,A,,9030,,1,BASIC,Program (P) Branch () Line 10
2021/02/25,17:30:21.270,6,A,,9030,,1,BASIC, DLL not found : DLL1
2021/02/25,17:32:14.073,6,A,,9030,,1,BASIC,Program (P) Branch () Line 10
2021/02/25,17:32:14.073,6,A,,9030,,1,BASIC, DLL not found : C:ARC InformatiquePcVue 12BinDLL1
2021/02/25,17:33:00.870,6,A,,9030,,1,BASIC,Program (P) Branch () Line 10
2021/02/25,17:33:00.870,6,A,,9030,,1,BASIC, DLL not found : C:ARC InformatiquePcVue 12BinDLL1.DLL

What I have tried so far (all with error still persists)

  1. Declare the dll as per above code
  2. Declare the dll with full path name to PcVue bin folder
  3. Declare the dll with full path name including extension
  4. Placed the dll inside TP folder

Does anyone have any trick or solution for this? How to declare custom DLL when PcVue is run from within VM?

Thanks,
Kantha

 
Posted : 25/02/2021 4:49 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

Hi Kantha,
That's an interesting issue!
I suggest you declare a system DLL and check if it works or not. That will give some clues.

By the way, not related to your issue but, I hope you know there is a basic system dll given the mouse position!!

Nico

 
Posted : 25/02/2021 6:31 pm
KASI
 KASI
(@k-simanjalamarcinfo-com)
Posts: 134
Estimable Member
Topic starter
 

Hello Nico,

I tried to declare the DLL in system, but it gave me some error. I am 100% sure the file is in the correct path.

I have requested the user to try to declare from his end and try.

I think the user knows about windows dll, but these guys they do a lot of custom program to be used with PcVue.

Thanks
Kantha

 
Posted : 26/02/2021 5:25 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

Misunderstanding !!
I was asking you to test a system dll not to register this dll in the system 🙂
For example this famous getMousePosition from our KB

DECLARE SUB GetCursorPos Lib "USER32" (HBF_POSI as long);


'-------- Function main
SUB main()
END sub


'-------- Use of function GetCursorPos
SUB test()
  DIM Mouse_Buffer as long;
  DIM Mouse_PosX as Integer;
  DIM Mouse_PosY as Integer;
  Mouse_Buffer = ALLOC_BUFFER(10);
  GetCursorPos( Mouse_Buffer );
  Mouse_PosX = IGET_BUFFER( Mouse_Buffer , 0); 'X coordinate is available at offset 0
  Mouse_PosY = IGET_BUFFER( Mouse_Buffer,4);   'Y coordinate is available at offset 4
  PRINT("Mouse_PosX = ",Mouse_PosX);
  PRINT("Mouse_PosY = ",Mouse_PosY);
  PRINT(" ");
  Free_buffer(Mouse_Buffer);
END SUB
 
Posted : 26/02/2021 5:31 pm
KASI
 KASI
(@k-simanjalamarcinfo-com)
Posts: 134
Estimable Member
Topic starter
 

That is interesting Nico.

I tried using the program you copied below, it is working fine to get the coordinates.

But using custom DLL, it always throw error DLL not found.

The only difference is, it fails to run in VM environment for custom DLL, but no problem to run the same in physical server.

So a bug?

Thanks,
Kantha

 
Posted : 02/03/2021 11:57 am
f.martin
(@f-martinarcinfo-com)
Posts: 148
Member Admin
 

Hi,

Have you already checked the dependencies ?
Maybe one is missing or with an incorrect version.

 
Posted : 02/03/2021 12:27 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

Ok Kantha, my feeling is the issue is not in PcVue.
So, the best way is to prove it.
I suggest you create a basic vbs script (.vbs) using the Dll (example: here)
I bet you will have the same issue and, here, no PcVue in the loop

Nico

 
Posted : 03/03/2021 5:22 pm
KASI
 KASI
(@k-simanjalamarcinfo-com)
Posts: 134
Estimable Member
Topic starter
 

Hello Florent and Nico,

Thank you so much for your assistance. Indeed there was some dependency on the DLL, that is why it failed to run in VM environment.
User have figured it out and the problem is solved now.

Thank you so much.
Kantha

 
Posted : 05/03/2021 2:21 pm