Third Party DLLs

Just starting out? Need help? Post your questions and find answers here.
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Third Party DLLs

Post by lesserpanda »

Hi guys, not sure if this is possible...

I have an SAP B1 System which has a DLL as a form of API access to the system. Normally in C# .NET, I'd add the resource and call it normally. I was wondering if I can use this DLL from PureBasic. I've been reading up on the PureBasic DLL creation and usage and haven't tried it out but thought if anyone knew.

Thanks
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Third Party DLLs

Post by spikey »

It depends what sort of interface the DLL implements.

If there is a C/C++ interface you should be able to connect to it via OpenLibrary and GetFunction and prototypes .

If there's a COM interface you should be able to use the COMate include file to access the objects with the ASM backend, I don't know if it works with the C backend (it wasn't at one stage). See viewtopic.php?t=37214 or viewtopic.php?t=74919, if you use modules.

If it's a .NET assembly it could be more difficult, various people have mentioned attempting to use .NET assemblies over the years but no-one has ever come back and said "Hey I got it working really well" to the best of my knowledge. See viewtopic.php?p=540316 though.
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Re: Third Party DLLs

Post by lesserpanda »

spikey wrote: Fri Nov 25, 2022 4:34 pm It depends what sort of interface the DLL implements.

If there is a C/C++ interface you should be able to connect to it via OpenLibrary and GetFunction and prototypes .

If there's a COM interface you should be able to use the COMate include file to access the objects with the ASM backend, I don't know if it works with the C backend (it wasn't at one stage). See viewtopic.php?t=37214 or viewtopic.php?t=74919, if you use modules.

If it's a .NET assembly it could be more difficult, various people have mentioned attempting to use .NET assemblies over the years but no-one has ever come back and said "Hey I got it working really well" to the best of my knowledge. See viewtopic.php?p=540316 though.
Hi @spikey, I used COMatePlus and managed to get thru creating an object H_RESULT = 0 #S_OK
SetProperty is also OK.
Invoking a method seems to be OK as well. However, for a return value/object, how do I get it from the Invoke method?

Like... in C# the COM object has a method
void GetLastError(out int errCode, [MarshalAs(UnmanagedType.BStr)] out string errMsg);
juergenkulow
Enthusiast
Enthusiast
Posts: 544
Joined: Wed Sep 25, 2019 10:18 am

Re: Third Party DLLs

Post by juergenkulow »

Please ask your questions, because switch on the cognition apparatus decides on the only known life in the universe.Wersten :DDüsseldorf NRW Germany Europe Earth Solar System Flake Bubble Orionarm
Milky Way Local_Group Virgo Supercluster Laniakea Universe
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Re: Third Party DLLs

Post by lesserpanda »

Sorry ... ABAP in SAP is for Hana. The DLL in question is for SAP B1. I'm happy using C# to connect and do stuff in SAP B1 at the moment. Just want to enhance and grow my PB skills.

I'm asking how to invoke method and get a return value using COMatePlus. Thanks.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Third Party DLLs

Post by spikey »

lesserpanda wrote: Sun Nov 27, 2022 3:04 am However, for a return value/object, how do I get it from the Invoke method?
You can't use Invoke in that instance, its for methods that don't return something. You need to use one of the Get*Property procedures matched for the type of the return (so GetIntegerProperty for an Integer, or GetObjectProperty for an object etc).

Have you got the COMate help file?
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Re: Third Party DLLs

Post by lesserpanda »

spikey wrote: Mon Nov 28, 2022 2:28 pm You can't use Invoke in that instance, its for methods that don't return something. You need to use one of the Get*Property procedures matched for the type of the return (so GetIntegerProperty for an Integer, or GetObjectProperty for an object etc).

Have you got the COMate help file?
Hi, yeah I've got the help file thanks. Still trying to learn the ropes of accessing a COM Object with PB. I'll give it a go. Thanks.
Post Reply