fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: how import dll functions with ref intern

how import dll functions with ref intern 1 year 3 months ago #4325

  SHirsch's Avatar Topic Author SHirsch Online Posts: 110
Hi all,

how can I import dll function with REF as parameter?
_DLL FUNC MyFunction( param1 REF WORD ) AS DWORD PASCAL:MyDll.MyFunction

In X#/VO this compiles without error message. With X#/Core I get 'error XS0214: Pointers and fixed size buffers may only be used in an unsafe context'

Background: I try to eliminate VO/Vulcan dependancies.

Regards,
Stefan

Please Log in or Create an account to join the conversation.

Last edit: by SHirsch.

how import dll functions with ref intern 1 year 3 months ago #4326

  Chris's Avatar Chris Away Posts: 1181
Hi Stefan,

This declaration should compile fine in Core, too. Are you sure the error is pointing in that declaration, or maybe it's reported in the code that calls it? Or in some other function?

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

how import dll functions with ref intern 1 year 3 months ago #4402

  Guy Deprez's Avatar Guy Deprez Offline Posts: 14
With the code below, same error X0214 in X#/Core...

[DllImport("user32.dll")];
STATIC METHOD ShowWindow(hWnd AS PTR, nCmdShow AS INT) AS LOGIC PASCAL

Guy

Please Log in or Create an account to join the conversation.

how import dll functions with ref intern 1 year 3 months ago #4403

  Guy Deprez's Avatar Guy Deprez Offline Posts: 14
Problem solved: PTR -> IntPTR

[DllImport("user32.dll")];
STATIC METHOD ShowWindow(hWnd AS IntPTR, nCmdShow AS INT) AS LOGIC PASCAL

Guy

Please Log in or Create an account to join the conversation.

how import dll functions with ref intern 1 year 3 months ago #4405

  Chris's Avatar Chris Away Posts: 1181
Hi Guy,

Just to explain, this is because the "PTR" type is a VO compatibility thing and it is not available in the Core dialect, only in the vulcan, VO and similar X# dialect settings. In Core, IntPtr can be used instead of PTR, as you already found!

Chris
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Page:
  • 1