简体   繁体   中英

How do I use the LoadLibrary function to import a dll file and use functions from dll file?

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.

HMODULE WINAPI 
LoadLibrary(
    _In_ LPCTSTR 
lpFileName
);

Also maybe insert #include <string>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM