LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

dll messages popup

hi,
 
 i would like use user interface library in my dlls , my main aim is to use messages popup , but in a labview RT environnement , it doesn't work..
Can you give me more explanations.
 
TheGame
0 Kudos
Message 1 of 2
(2,832 Views)

RT is a headless non-interactive system. There really is no good reason to have a user interface downloaded on an RT enviornment. If you want to notify the system about some error or message, you can use the tcp libraries to communicate with a client across the network. Or you can print messages to the screen.

Include this function in your project

#include <windows.h>

typedef int (*RTPRINTF)(const char*);

int  CVIFUNC_C RTprintf(const char * debugstring)
{

   HINSTANCE hinstLib;
   RTPRINTF rtprintf = NULL;
   int returnresult = -1;
  
   hinstLib = LoadLibrary("msvcrt");
       // If the handle is valid, try to get the function address.
 
    if (hinstLib != NULL)
    {
        rtprintf = (RTPRINTF) GetProcAddress(hinstLib, "printf");

        // If the function address is valid, call the function.

        if (NULL != rtprintf)
        {
            returnresult= rtprintf(debugstring);
        }

        // Free the DLL module.

        FreeLibrary(hinstLib);
    }

    return returnresult;
}

Then if you want to use this instead of the default printf add the following to your C file

#ifdef _LINK_CVI_LVRT_
int  CVIFUNC_C RTprintf(const char *, ...);
#define printf RTprintf
#endif


This way, printf will print messages to the RT console.

Bilal Durrani
NI
0 Kudos
Message 2 of 2
(2,816 Views)