🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Boris Epel Mon, 13 Aug 2007 18:48
Explicit link to DLL, problem in BCB but not in MSVC
#1489
Author: Boris Epel
Date: Mon, 13 Aug 2007 18:48
22 lines
1681 bytes
Hi ALL!
I call functions from National Instruments DAQ mx dll ("nicaiu.dll"). 
On _some_ computers code compiled in BCB 6.0 generates memory violation 
when calling one of the functions (DAQmxGetChanType). The same code in 
Visual C works fine everywhere.

The code is pretty standard (http://www.specman4epr.com/NIDAQtest.zip), 
declaration of function is correct.
.h:
typedef int32 (__CFUNC *DAQmxGetChanType_f) (TaskHandle taskHandle, 
const char channel[], int32 *data);
.c:
HINSTANCE handle = LoadLibrary(_library);
DAQmxGetChanType_f  DAQmxGetChanType = (DAQmxGetChanType_f) 
GetProcAddress(handle, "DAQmxGetChanType");
...
first call of this function causes crash on _some_ computers.

Did anybody experience similar problems ?

Regards,
Boris
Re: Explicit link to DLL, problem in BCB but not in MSVC
#1493
Author: Bob Gonder
Date: Mon, 13 Aug 2007 22:25
15 lines
1332 bytes
Boris Epel wrote:

>HINSTANCE handle = LoadLibrary(_library);
>DAQmxGetChanType_f  DAQmxGetChanType =
>	 (DAQmxGetChanType_f) GetProcAddress(handle, "DAQmxGetChanType");

>first call of this function causes crash on _some_ computers.

Which function?
LoadLibrary ?
GetProcAddress ?
Or some code you haven't shown such as
DAQmxGetChanType ?

Do you check that the setup functions succeed?
Re: Explicit link to DLL, problem in BCB but not in MSVC
#1495
Author: Boris Epel
Date: Tue, 14 Aug 2007 16:59
42 lines
2419 bytes
Hi Bob,

thanks for the reply!
The application code is shown below. the exception is cached by 
try/catch statement. all necessary error handling is done - no errors in 
linking of dll. The function pointer (DLL offset) is correct. Other 
(tested) functions of dll are fine.

In MSVC code VCL objects are exchanged for MFC, nothing else changed.
Regards,
Boris

.cpp:
    LastError = DAQmxLoadTask (Edit1->Text.c_str(), &task);
    if( DAQmxFailed(LastError) )
          PostErrorString("DAQmxLoadTask:", LastError);
     else
      {
        Memo1->Lines->Add(AnsiString().sprintf("Task '%s' is beeng 
loaded...", Edit1->Text.c_str()));
        char buffer[256];
        for(uInt32 i=1;;i++)
          if( DAQmxFailed(LastError = DAQmxGetNthTaskChannel (task, i, 
buffer, 256)) ) break;
           else
            {
              int32   data;
              float64 fdata;

              Memo1->Lines->Add(AnsiString().sprintf("Loading channel 
%d: %s", i, buffer));
       try {
/****************** Here an exception generated **********************/
              if( DAQmxFailed(LastError = DAQmxGetChanType(task, buffer, 
&data)) )
/*********************************************************************/
                PostErrorString("DAQmxGetChanType:", LastError);
              isPassed = true;
           } catch(...)
           {  Memo1->Lines->Add(AnsiString("Crash on DAQmxGetChanType."));
           }
       }
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads