-1

I need to load a .dll file from another company code in order for me to call its function. But how do I load it when I dont know how to set its variable? The dll file is "Interop.OphirLMMeasurementLib.dll" and this is the cut out from data sheet.

"The OphirLMMeasurement COM object follows the standard COM practice of returning an HRESULT from its methods. The HRESULT can be passed to GetErrorFromCode to get a descriptive string, or the standard COM GetErrorInfo function can be called (see documentation for your environment). Some client environments (such as VB6 and all .NET languages) do not return this HRESULT from the method call; instead they throw an exception when a method returns a failure HRESULT. This exception will normally contain within it the error number and the descriptive string.

----------


3.3 Methods and Events

3.3.1 Device Communications

Close

CloseAll

GetKnownWirelessDevices

OpenUSBDevice

OpenWirelessDevice

ResetAllDevices

ResetDevice

ScanUSB

ScanWireless

So how do I call the function of ScanUSB from this .dll file?

MSalters
  • 173,980
  • 10
  • 155
  • 350
Shaunyong
  • 1
  • 1
  • Did they not provide a header and import library with the DLL? The latter you don't *strictly* need, but it would seem helpful they would at least provide the former. You may want to check the package the DLL came in. – WhozCraig Apr 17 '15 at 04:52
  • The Interop library was meant for a .NET program. In native C++ you'll have to use the #import directive to import the type library. Usually embedded in the DLL. There is a learning curve to writing COM client code in C++, you'd be better off using a .NET language. – Hans Passant Apr 17 '15 at 06:11
  • They did not provide any header and import library method, but they did provide a usable demo for VB, Csharp, matlab and labview which i'm not familiar with. I was given the task to use only C++ and no other language. – Shaunyong Apr 20 '15 at 01:03

1 Answers1

0

The important word is COM. Short for Component Object Model, this is Microsoft's language-neutral mechanism to call methods on objects.

In this case, ScanUSB is a method on objects of the OphirLMMeasurement type. I don't know from just this bit how to get such an object - CreateInstance is the likely way. I suspect OpenUSBDevice will be necessary then, before ScanUSB. But we'd also need to know the arguments, and you left out those parts of the documentation.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • The only document that they provide is this. https://www.dropbox.com/s/m6i8z6exfoa1swv/OphirLMMeasurement%20COM%20Object.pdf?dl=0 and I must need to use C++ language – Shaunyong Apr 20 '15 at 01:04