LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help: error 1097

I wrote a dll below simply to study string between labview & C++:

int strTest (CString pathCStr)
{
char* pathChar = "";

strcpy(pathChar, pathCStr.GetBuffer());
pathCStr.ReleaseBuffer();

return ((int)pathChar[0]);
}

The compilation was OK. But when I call it in labview, I was told
error 1097.

All parameters are correctly connected. Where is the problem?

Thank you!
0 Kudos
Message 1 of 4
(3,971 Views)
Hi Andrew,

I haven't had this problem before, but several related problems have been solved by this KB before.

Please look into that and see if it's helpful
Van L
NI Applications Engineer
Message 2 of 4
(3,957 Views)

@Andrew Chang wrote:

All parameters are correctly connected. Where is the problem?



In your understanding of C. You've already allocated a fixed amount of memory by initializing pathChar. You can't use strcpy to copy a string onto that variable because you will stomp on memory that doesn't belong to pathChar.

Message 3 of 4
(3,945 Views)

hello,

 

i have a simmilar problem. could anyone please take a look at following code:

 

// ant_sendevent.cpp : Definiert die exportierten Funktionen für die DLL-Anwendung.

//

 

#include "stdafx.h"

#include <stdio.h>

#include "ant_sendevent.h"

#include "extcode.h" //labview inlcude

#include <cstdlib>

 

//definitonen für ANT_Load und UnLoad

 

static HMODULE hANTdll;

static BOOL bLoaded = FALSE;

UCHAR *aucResponseBuffer;

UCHAR *aucChannelEventBuffer;

LVUserEventRef *antEvent;

LVUserEventRef *antResponse;

char* myeventbuffer[10];

char* myresponsebuffer[10];

 

 

//Functionen der ANT DLL

P_ANT_ARF         ANT_AssignResponseFunction;

P_ANT_AEF         ANT_AssignChannelEventFunction;

 

 

// Dies ist das Beispiel einer exportierten Funktion.

///////////////////////////////////////////////////////////////////////

ANT_SENDEVENT_API BOOL ANT_Load(void)

{

   if (bLoaded)

      return TRUE;

 

   hANTdll = LoadLibraryA("ANT_DLL.dll");

   if (hANTdll == NULL)

      return FALSE;

 

   ANT_AssignResponseFunction = (P_ANT_ARF) GetProcAddress(hANTdll, "ANT_AssignResponseFunction");

   ANT_AssignChannelEventFunction = (P_ANT_AEF) GetProcAddress(hANTdll, "ANT_AssignChannelEventFunction");

 

   if (ANT_AssignResponseFunction == NULL)

      return FALSE;

   if (ANT_AssignChannelEventFunction == NULL)

      return FALSE;

   

   bLoaded = TRUE;

   return TRUE;

}

 

///////////////////////////////////////////////////////////////////////

ANT_SENDEVENT_API BOOL ANT_UnLoad(void)

{

   if (hANTdll != NULL)

   {

      FreeLibrary(hANTdll);

 

   }

   bLoaded = FALSE;

   return FALSE;

}

//my CallBack Function for Events

BOOL ANT_ChannelEventFunction(UCHAR ucChannel, UCHAR ucEvent)

{

char* ucChannel_ = reinterpret_cast<char*>(ucChannel);

char* ucEvent_ = reinterpret_cast<char*>(ucEvent);

strcpy(myeventbuffer[10], (char*)ucChannel);

strcpy(myeventbuffer[10], (char*)ucEvent);

SendEvent(antEvent,myeventbuffer[10]);

return TRUE;

}

//my CallBack Function for Response

BOOL ANT_ResponseFunction(UCHAR ucChannel, UCHAR ucResponseMesgID)

{

char* ucChannel_ = reinterpret_cast<char*>(ucChannel);

char* ucResponseMesgID_ = reinterpret_cast<char*>(ucChannel);

strcpy(myresponsebuffer[10], (char*)ucChannel_);

strcpy(myresponsebuffer[10], (char*)ucResponseMesgID_);

SendResponse(antResponse,myresponsebuffer[10]);

return TRUE;

}

 

ANT_SENDEVENT_API BOOL functioncaller(UCHAR ucChannel_, UCHAR* aucResponseBuffer, UCHAR* aucChannelEventbuffer)

{

    aucChannelEventBuffer[MESG_DATA_SIZE];

aucResponseBuffer[MESG_RESPONSE_EVENT_SIZE];

    if(ANT_AssignResponseFunction != NULL  && ANT_AssignChannelEventFunction != NULL)

{

ANT_AssignResponseFunction(ANT_ResponseFunction, aucResponseBuffer);

ANT_AssignChannelEventFunction(1, ANT_ChannelEventFunction, aucChannelEventBuffer);

return TRUE;

}

return FALSE;

}

 

ANT_SENDEVENT_API void SendEvent(LVUserEventRef *antEvent, char* Eventmsg)

{

PostLVUserEvent(*antEvent,(void *)&Eventmsg);

return;

}

 

ANT_SENDEVENT_API void SendResponse(LVUserEventRef *antResponse, char*Responsemsg)

{

PostLVUserEvent(*antResponse,(void *)&Responsemsg);

return;

 

i always get the 1097 error but it seems i am way to stupid to solve this. i have read the kb article, but without any result (and i am net to c++ so its very, very hard)... please - could anyone help?

 

thanx

martin 

0 Kudos
Message 4 of 4
(3,727 Views)