External function with a pointer to a callback within a DLL function

Hello.

I am loading a DLL and try to call a function with the following prototype:

Func1(HANDLE, hHandle, LPVOID (*pCallback)(UINT, UINT LPVOID), CHAR* sPath)

Now, I have no problem with the types of variables, because CVI 9.0.1 recognizes each of them and I have no problem with LoadLibrary() and GetProcAddress().

But, how to pass a pointer to a callback function that is inside the DLL, I am trying to use.

I tried to declare the callback like this:

LPVOID (CALLBACK Callback)(UINT iDevNo, UINT evEvent, LPVOID pData);

and call the Func1 function like this:

(Func1)(hHandle, &Callback, NULL);

but it irritates me:

Symbol not defined "_Callback@12" referenced in "source.c.

Hopefully I can help.

I appreciate your time on this issue.

Kind regards.

Hi Daniel,.

He must first make sure that the callback function is exported by the DLL, so the program that uses the DLL can access the identifier of the function name. Then you must make sure that you call GetProcAddress not only on Func1, but also on the exported callback function. You must store the two address function values in their respective function pointers. You can then pass the pointer to callback in the form of argument to the call to Func1.

It's probably cleaner if you set of typedefs for all your function pointers, in the calling program:

typedef LPVOID (__stdcall * CallbackType) (UINT, UINT, LPVOID);
typedef? (__stdcall * Func1Type) (HANDLE, hHandle CallbackType, CHAR *);

...

CallbackType CallbackPtr;
Func1Type Func1Ptr;

...

dllHandle = LoadLibrary ("... ») ;
CallbackPtr = (CallbackType) GetProcAddress (dllHandle, 'Callback');
Func1Ptr = (Func1Type) GetProcAddress (dllHandle, "Func1");

...

Func1Ptr (..., hHandle, CallbackPtr, NULL);

Boa kind!

Luis

Tags: NI Software

Similar Questions

  • Error: Function of ms - dos invalid when copying on external drive with Windows 7

    FUNCTION OF MS BACK INVALID WHEN PLAYBACK EXTERNAL DRIVE WITH WIN 7

    Hello

    1. you try to save a data of the C drive on an external hard drive using the Windows backup feature?

    2 does this problem occur when you try to copy / paste normally?
    3. What is the accurate and complete error message?

    If you try to copy and paste the data manually, then try the fix to resolve the problem:
  • Clientdata bad pointer in a callback function

    Hello

    I'm trying to pass a data object to a callback function when the load a document.

    This is my code:

    AVAppRegisterNotification (AVDocDidOpenNSEL, gExtensionID, ASCallbackCreateNotification (AVDocDidOpen, (void *) myNotificationCallback), (void *) & aClientData);

    The callback function is the following:

    ACCB1 Sub ACCB2 myNotificationCallback(void *clientData)

    {

    ....

    }

    However my address pointer in the callback function clientData is not the same as the address when I put it in the AVAppRegisterNotification function.

    How is that possible?

    Consider, for example: the recall will need to know what AVDoc is just opened, which is not possible if the only parameter is clientData.

  • Tecra S4: cannot switch automatically to an external monitor with APR 3 +.

    Hello

    I used a Tecra S4 (with Windows XP Prof.) with monitor 3 + and with an external 19 "Advanced Port Replicator. If I connect my laptop with the Port Replicator, it will automatically switch to the external display. I have to use the function "FN" to move."

    I signed up the external monitor with "use this device as the primary monitor.
    I don't have this problem with my other laptop Toshiba Tecra A3.

    Now, I think the problem is the geforce graphics card.

    Does anyone have the same problem?
    Thanks for the help and sorry for my bad English; (o)

    Hello

    It works with Tecra S4, too.

    Install new Modules of Commopn
    http://support.toshiba-tro.de/Tedd-files2/0/CMOD-en-20071119111948.zip

    Install the latest Toshiba laptop Extensions
    http://support.toshiba-tro.de/tools/Tecra/TS4/XP/TME/TME-TS4-XP-38400xp-en.zip

    Install the display device change Utility
    http://support.toshiba-tro.de/tools/Tecra/TS4/XP/DPL-change-drv/dspdevchge-TS4-XP-2500-en.zip

    Enter in Control Panel, start Extension mobile controls.
    Go to the tab 'Change of display device' and activate the Service.

    Now, it should work.

  • Problem with access point or wireless adapter

    Hello world

    tried to connect to my WiFi, but the convenience store detects that the problem with access point or wireless adapter.
    The drivers are up-to-date and functioning normally. There were discussions on BIOS but I don't know if I would be able to complete the task without bricking your laptop.

    Is there any online support?

    Hi smert

    Your message is not really useful.
    Why? Because no one knows all the details of the laptop, wireless network card system...
    So please would you be kind enough to provide more details.

    But despite the missing information, I recommend:
    (1) reset your router WLan
    (2) check the connection to the WiFi unsecured. (of course for testing purposes)
    (3) check the different (WPA/WPA2 AES, TKIP) encryption

  • How to call external functions without one. DLL (just using a.) H and. LIB file)?

    Hi all

    in fact, I am facing difficulties on how to get an external function is called in CVI (Version 2009).

    I was delivered with a. H file and a. LIB file to call an external function of my project CVI. The. H file looks like this:

    void exportedFunction(double *parameter);
    

    As far as I know, the external function was written with MS Visual C++ 6.

    So, I tried to link statically to the al extern like this function:

    -Add the. H file and the. LIB file to the CVI project

    -#include the. Folder H when I needed to call the external function

    -do the external function call

    During construction I get unresolved CVI external function call error, so this seems not work.

    I did some research autour and stood up with two possible problems. Maybe one of you can help me get a bit further and do work things out.

    (1) of the code of the 'real' function inside the DLL file that was not delivered to me. Or y at - it a way to get concrete results (calling external functions) with just one. H and a. LIB file (with none. Included DLL file)?

    (2) the external function does not export according to the rules of Style 'C '. The signature of the function in the. H file shows some things don't like

    extern "C" __declspec(dllexport) void __stdcall ...
    

    Or maybe it's a combination of these two issues (missing. DLL + bad export style function)?

    I guess I could get around the incorrect service export style when I managed to write a wrapper around the original function that actually uses Style C exporters. But I guess I need to the. DLL file for this test as well.

    Thank you very much for your answers.

    Best regards

    Bernd

    There is no need for the stuff of dllexport. There is also the option of a static library without any DLL.  But the "extern"C"' is essential, because it forces the C++ compiler, which was probably used to compile the library to use the C calling convention.

    If you are unable to ask the library vendor to provide a version that was compiled using C calling convention is the way to write a wrapper with VC ++ 6 around this library that functions using C calling convertion reexports. Something like

    extern 'C' myfunc1 type0 (type1 arg1,...) {

    Back to func1 (arg1,...);

    }

    for each function, you must use.

    BTW. "unresolved symbol" is the error message from the linker, you can expect if you try to bind the C code against a generation of library with the C++ calling convention.

  • What is a red dot with exclamation point average

    I have windows XP and lately the red dots with exclamation points appear on more and more of my file icons.

    They appear in the lower right of the icons of file.  I see no difference in functionality, but he fears that

    I have no idea what it means, and it is spreading in addition to my files.  What does that mean?

    You have some sort of software to backup installed, for example, Carbonite, Mozy, Norton 360?

    Many of these applications use overlays on file icons to indicate the status of the backup.  What you describe sounds like Avast! Backup--> https://support.avast.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=1000#idt_0108

  • Personal warping of music with anchor points?

    I need to get a model of very specific chain with a musical score (2 measures). When I take the steps and back up I can use string functions that do not include a precise control. I would like to take 2 measures, like a 'flag' warp and twist with anchor points, but this does not seem possible. Any help?

    Make art artbrush out of it. Draw a curved line, and then apply to the brush.

    You can also refine a deformation of the envelope using the gradient mesh tool. But it does not work when you apply the deformation under effect. It only works when you apply good object > envelope.

  • using the iMac 27 inch mid 2011 as an external monitor with a PC via mini DisplayPort

    I find conflicting information via web search to be able to use my iMac 27 inches, mid-2011 as an external monitor with a PC. Is it possible to use the iMac as an external display via the Display Mode target between Thunderbolt port of the iMac with a PC equipped with a mini DisplayPort?

    Of course, I hear it's possible with the appropriate cable. But if it is not possible, I would like to know for sure.

    Thanks in advance for your help with this. _henry

    Target display mode is Mac to Mac only. Use your iMac as a display with the target - Apple Support Display Mode

  • Qosmio X 500 - 13R: picture on external monitor with resolution 2560 x 1440 is blurred

    Hi all

    I have a computer laptop X 500 - 13R Toshiba Qosmio, although 2 years, still a great piece of hardware.

    I just bought a new monitor 27 "U2713HM which supports a resolution of 2560 x 1440.

    Computer video card notebook (GTX 460 m) supports a resolution higher than through a digital connection, so I used a HDMI cable to connect.

    Via Control Panel Nvidia, I could create a custom resolution, but the image is not clear / is blurred.
    It is readable, but it's just not everything.

    Tried with HDMI 1.4, without success.
    I volunteered to connect through Dual Link DVI cable, but the phone doesn't have a DVI connector, and I doubt the adapter will help.

    Anyone has a suggestion how to fix this problem?

    Thank you.

    I would like to share my experience using an external monitor with a HDMI cable.
    My monitor supports both HDMI and DVI port.
    First of all, I plugged my laptop on the external monitor using a HDMI cable to HDMI.
    But the fonts and the picture was not clear. I used the resolution 1920 x 1080

    Then I went to the DVI port. I plugged the laptop s HDMI port to monitor s port DVI (HDMI/DVI cable) and that solved my problem.

    I'm not quite sure the relevance of m this could be for you, but it worth the try

  • How can I use external speakers with my MacBook Air?

    How can I use an external speaker with my MacBook Air? I have a Samsung wireless speaker.

    They are Blue Tooth? If Yes, then you need to pair by using the preferences of BT.

  • How to use two external monitors with my laptop?

    I have a new Pavilion dm4-301 d cl Entertainment PC.   My OS is Windows 7.   I'm used to using two external monitors with a docking station.   This new laptop lacks a docking station.  What should I do use two external monitors?

    Certainly not without a dock, but even with laptop HP well enough docks limit you to one of the ports on the external monitor, even if there are two on the dock. We used a device called an Atlona AT-HDPIX2 which is a USB to hdmi adapter. It provides a feature of third monitor for a laptop... use the native external port of the screen and the computer screen internal, then this device gives a third control that is fully configurable to display Windows 7 interface... clone, extend, etc.. It allows a full HD resolution and is pretty responsive for games even light.  HP does not have any true docking station for your laptop.

  • Lack of external function DAQ channel read

    Hello

    I did a few installers to share on the network variables, one is based at DAQmx readings of analog channels use modules of simulations and the second donkey receives variables shared these radings... I thought it was pretty good, because I have the main application (channels read and share variables) in my main PC (which has istalled LabVIEW 2012) and the other track in a regular PC (no software OR installed until my Installer Act) and it worked fine. However, I installed the main application in the regular PC and I got an error stating: lack of external function DAQmx read single sample DLB... I guess I should include in my Installer features on DAQmx but I Don t know which ones to avoid this error and be able to install my apps in any PC... Thanks I await your advice!

    Well, I found the solution...

    I've just included confiuration NI DAQmx MAX support to my app Installer and I solved the problem...

  • Call and open an external Excel with exec system vi

    Hello!

    I would like to know how I could call and open an external Excel with the exec system vi. I am able to call a txt file, but I can't do it with an excel file...

    Thank you very much in advance.

    It should work like any other file, it opens in the default program for the file extension that if you double click on it.  Here is an example if code that I use.

  • laptop connected to an external monitor with vga cable issues?

    1The votefavorite

    I use a Sony Vaio e series laptop running windows 7 Home premium 64-bit, which I always connect to an external monitor with a VGA cable.

    I put graphics options to display only on the external monitor and I would like to close the lid of the laptop. In the power settings I put it do nothing when the lid closes.

    When it is connected to the external screen I am able to look at the screen very well if the lid of the laptop is open. But whenever I close the lid, the display on the external monitor is turned off.

    I have tried everything I can think of as the use of a keyboard to toggle the display, change the plan to plug the monitor off before and after and even more, to much to list etc.

    I actually did it on my HD TV using a Hdmi cable that allows me to close the lid. But I want to use it only on my monitor that is sadly only VGA.

    I know I'm not alone here, I found many forums on the same issue, but nobody seems to have an answer. It is always with the help of a VGA cable when I find others with the same problem.

    Does anyone know where a response?

    It seems either VGA may be quite old now since the introduction of HDMI, that Microsoft has not bothered to look on this or get out an update to resolve this issue. Sorry it's just very frustrating because cannot find an answer, and I don't like the laptop overheating or wasting money on energy.

    (1) right click on your power Option icon on the taskbar

    (2) will take you to Options below

    Control Panel:

    Choose what closing the lid"this choice is the 3rd in your list of choices

    The next screen will allow you to configure your choice:

    When I close the lid:

    On battery: do nothing and

    Plugged in: Do nothing

    This will prevent your system/video to go to sleep or stopping

    Hope this helps

Maybe you are looking for

  • Cannot type a short message: "caractΦres."

    We'll see if it works... I'm trying to ask a short question in the section of Xcode, typed by hand from scratch, nothing not stuck, no code or newspapers or images, entirely ASCII, but I can't post, no matter how I change it: "the message contains in

  • I down loaded the new Fire Fox last night and this morning I couldn't send messages from my mail.

    I use now explore.When I press on compose everything is in place but I can't yet put the address. It is as if it is locked.When I try to answer, I have the same problem. Also, I can't pass.Thanks for any help.

  • Problem of sound on Satellite U200 - 10 h

    I have a problem with my Toshiba U200 - 10: 00. There is no sound through speakers or headphones.All the drivers are installed correctly. I reinstalled Windows Vista from recovery CD but it did not help.What can I do to fix this?

  • compare the text file to test the system

    Hi there everyone, can someone help me please. I have already created the Subvi. He already did what I wanted. It's the only way I know how. BUT... I need another way to do before having a new system. I'll have to change the code. I want to just edit

  • Effect of lack in movie maker

    My Movie Maker included with windows XP had no video effects there were only two effects fast and slow, but I was looking for turn option how can I get what there is not under video effectsI have to download it? If so how? Please answer in detail