LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL : LoadExternal...

Hello,
I've got problem trying to "GetExternalModuleAddr" from a function inside a DLL that is loaded with "LoadExternal()". I've already done that in the past but I've got an error (-25). Here's my code :
Inside the DLL :
I've tried both __stdcall and DLLEXPORT:
int __stdcall DEV1502_Load( void *pvData, char *va_psPath, int va_hPanel )

Inside my application :

vl_iModuleId = LoadExternalModule( "1502.lib");
if( vl_iModuleId >=0 )
{
vl_pfDEV_Load = GetExternalModuleAddr ( vl_iModuleId, "DEV1502_Load", &iStat );
}

The iModuleID is correct, but I can't reach the function: iStat=-25.
SO, I've used the SDK function and it works !.
I've to load "1502.dll" instead of "1502.lib" with CVI function. Why ?

I use CVI beta 7 and Windows
2000.

Thank's for any advice
0 Kudos
Message 1 of 4
(3,065 Views)
Have you tried this with a released version of CVI? The Developer Exchange forum is not meant to host beta-related questions as beta customers are a very small set of the large CVI customer base. If you think this is related to the latest beta of CVI, please email cvi.beta@ni.com.

Otherwise, can you email Technial Support at http://www.ni.com/ask with the DLL you mention above (1502.dll) and the project you are using to load it. We haven't heard of this issue before. In your email, please specify if you are creating the DLL with CVI (what version) and if Dependency Walker or a similar utility shows the exported function correctly (DEV1502_Load).

Thanks in advance,
Azucena
NI
0 Kudos
Message 2 of 4
(3,065 Views)
I would suggest to use the loadlibrary from the SDK, then GetProcAddress and
then a function pointer to make a call. Feel free to quickly review the page
: http://perso.wanadoo.fr/philippe.baucour/pratiquer/ptrfn/ptrfn.html

You may want to try the code below
//---------------------------------
#include
#include
#include

// FCTX est donc un pointeur sur une fonction qui attend un int, un char *
etc...
typedef int (*FCTX)(int hWnd, char *Texte, char *Titre, unsigned int Type);

// Nom de la fonction que l'on veut appeler
#define NOM_FONCTION "MessageBoxA"

// Nom de la DLL � charger
#define NOM_MODULE "user32.dll"

int main (int argc, char *argv[]) {

static char ModPath[255]="C:\\WINNT\\system32\\";

int Status;
FCTX Fn_Ptr;
HMODULE ModId;
wchar_t bob;

strcat (ModPath, NOM_MODULE);

// Chargement de la DLL
ModId = LoadLibrary(ModPath);

// R�cup�re l'adr de la fonction
Fn_Ptr = (FCTX)GetProcAddress(ModId, NOM_FONCTION);

// Appel de la fonction avec passage de param�tres
Status = Fn_Ptr(0, "Le texte de la boite de dialogue", "Le tire", MB_OK);

// D�chargement de la DLL
FreeLibrary(ModId);

printf ("Apr�s appel de la fonction dans le module, le status = %i\n",
Status);
printf("Strike ENTER to exit :");
getchar();
return(0);
}
//--------------------------------------------------


In addition, for what I know using these function was explain during the
last CVI Days in France. You may want to contact NI France to get a copy of
the CVI Day Manual (if yet available). In any case a huge zip file is
available on ni.com/france/cvi


--
Philippe
Feel free to visit : http://perso.wanadoo.fr/philippe.baucour



"Pierre" a �crit dans le message de news:
506500000008000000367D0000-1042324653000@exchange.ni.com...
> Hello,
> I've got problem trying to "GetExternalModuleAddr" from a function
> inside a DLL that is loaded with "LoadExternal()". I've already done
> that in the past but I've got an error (-25). Here's my code :
> Inside the DLL :
> I've tried both __stdcall and DLLEXPORT:
> int __stdcall DEV1502_Load( void *pvData, char *va_psPath, int
> va_hPanel )
>
> Inside my application :
>
> vl_iModuleId = LoadExternalModule( "1502.lib");
> if( vl_iModuleId >=0 )
> {
> vl_pfDEV_Load = GetExternalModuleAddr ( vl_iModuleId,
> "DEV1502_Load", &iStat );
> }
>
> The iModuleID is correct, but I can't reach the function: iStat=-25.
> SO, I've used the SDK function and it works !.
> I've to load "1502.dll" instead of "1502.lib" with CVI function. Why ?
>
> I use CVI beta 7 and Windows 2000.
>
> Thank's for any advice
0 Kudos
Message 3 of 4
(3,065 Views)
C'est ce que j'ai fait MrBAUCOUR !!!mais je voulais comprendre pourquoi çà ne marche pas en CVI !

Merci.

(P.DURIEZ)
0 Kudos
Message 4 of 4
(3,065 Views)