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
Third Party DLLs
Re: Third Party DLLs
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.
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.
-
- User
- Posts: 65
- Joined: Tue Feb 11, 2020 7:50 am
Re: Third Party DLLs
Hi @spikey, I used COMatePlus and managed to get thru creating an object H_RESULT = 0 #S_OKspikey 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.
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);
-
- Enthusiast
- Posts: 556
- Joined: Wed Sep 25, 2019 10:18 am
Re: Third Party DLLs
How to call DLL functions from the client in ABAP programs
Enhancement: How To Call DLL Functions In ABAP
SAP connectors
SAP .NET Connector 3.1 Programming Guide
Enhancement: How To Call DLL Functions In ABAP
SAP connectors
SAP .NET Connector 3.1 Programming Guide
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
Milky Way Local_Group Virgo Supercluster Laniakea Universe
-
- User
- Posts: 65
- Joined: Tue Feb 11, 2020 7:50 am
Re: Third Party DLLs
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.
Re: Third Party DLLs
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).lesserpanda wrote: ↑Sun Nov 27, 2022 3:04 am However, for a return value/object, how do I get it from the Invoke method?
Have you got the COMate help file?
-
- User
- Posts: 65
- Joined: Tue Feb 11, 2020 7:50 am
Re: Third Party DLLs
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.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?