0

Question

I would like to make a c++ file that simply calls the one function in the .dll file that I need and returns the value. However, I have been trying to use LoadLibrary() to no success at all. When I hover over LoadLibrary, it says "identifier "LoadLibrary" is undefined". I figured that importing windows.h and winbase.h should be enough to define the library...

#pragma once
#include <windows.h>
#include <iostream>
#include <WinBase.h>
#include <E:\Users\Zachary\Anaconda3\include\Python.h>

int main()
{
    HINSTANCE dll = LoadLibrary("cbw64.dll");
}

More details about my project design

I am currently working on a senior design project where I have to connect to an OM-USB-TC Data acquisition unit from Omega. Ultimately, all I need to do is get temperature data from this unit and give it to python to do some cool graphing stuff. However, I do not have any communication protocol for this daq as the company is loath to give it out. So, I have to use the universal library that they have provided.

To use the library, I need to import a .dll file. However, it's tricky for python to use this as the temperature data is stored in an in-out variable for programming in c, and it seems like python doesn't play well with in-out variables.

Cecilia
  • 4,512
  • 3
  • 32
  • 75
zbiegler
  • 1
  • 1
  • Does the code compile, or are you just assuming that it won't due to what you see when you hover over it? Also, your question isn't really clear, you should probably reword this to just be about the question - we don't need to know all of the other information, if all you're asking about is why the LoadLibrary function is saying that it's undefined when you hover over it. – Random Davis Mar 14 '17 at 20:27
  • Check out this post: http://stackoverflow.com/questions/8696653/dynamically-load-a-function-from-a-dll – Anon Mail Mar 14 '17 at 20:28
  • Thanks for the reply. It does not compile and will not load the .dll file. The question is really: how do I make the LoadLibrary function work to import a dll file and then use the functions in said dll file. – zbiegler Mar 14 '17 at 21:16
  • Hi Zach, I edited your post to put more emphasis on the heart of your question by re-ordering the paragraphs, but if you feel that my changes obscure some important details, please edit it again. Just keep in mind that you'll get more answers if readers can scan your question quickly. – Cecilia Mar 14 '17 at 21:45
  • Anon, that's the post where I got the idea to use the LoadLibrary() function in the first place. The problem is that I cannot load the library when I define it in that manner. – zbiegler Mar 14 '17 at 21:46

1 Answers1

1
HMODULE WINAPI 
LoadLibrary(
    _In_ LPCTSTR 
lpFileName
);

Also maybe insert #include <string>

  • I appreciate the reply. However, I don't see how this assigns the loaded library to a position that I can call. Does it simply load in the library and allow me to use the functions? – zbiegler Mar 14 '17 at 21:25
  • Yes. Also, make sure that your file directory and file name are correct. Any little errors such as a missing character can cause this error. – FutureProgrammer Mar 14 '17 at 22:00
  • I'm assuming I need to give a value to lpFileName in order for this to work. So, I gave it a string with the complete file path (which is what I seem to understand from [link](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx). However, after calling the function (correctly to the help file from Omega) I receive an error that says "error C3861: 'cbTIn': identifier not found" – zbiegler Mar 14 '17 at 22:21
  • Check this out: [link](http://stackoverflow.com/questions/12723107/error-c3861-initnode-identifier-not-found) – FutureProgrammer Mar 15 '17 at 11:06