LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Always getting "Invalid Argument" error on CNV functions

Hallo,

I'm quite new to LabView/LabWindows/CVI. I'm trying to create a very simple C++ application that will exchange Network Shared Variables with a LabView VI.

But no matter which function I call, I always get the error "Argument is invalid". For example when creating a browser to browse for available variables:

 

int _tmain(int argc, _TCHAR* argv[])
{
  CNVBrowser* browser = NULL;
  int retVal = CNVCreateBrowser(browser);

  if(retVal != 0)
  {
    const char* error = CNVGetErrorDescription(retVal);
    std:: cout << error;
  }//end if

  if(browser != NULL) CNVDisposeBrowser(*browser);

  return 0;
}

 This gives me a return value of -6393 which means "Argument is invalid".

I suppose there is something very basic I'm doing wrong. Can anyone help me out?

 

Thanks!

0 Kudos
Message 1 of 4
(4,245 Views)

I should say that you need to use the function this way:

 

CNVBrowser browser;
int	error;

error = CNVCreateBrowser (&browser);

 

The function should correctly return the handle that it creates. While executing your code inside CVI environment you are likely to get a "Null pointer passed to library function" error.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(4,241 Views)

BorisBrock:

 

You are getting confused over what should be a pointer. The code ought to read something like:

 

 

int _tmain(int argc, _TCHAR* argv[])
{
  CNVBrowser browser = NULL;
  int retVal = CNVCreateBrowser(&browser);

  if(retVal != 0)
  {
    const char* error = CNVGetErrorDescription(retVal);
    std:: cout << error;
  }

  if (browser)
    CNVDisposeBrowser(browser);

  return 0;
}

 

HTH!

--
Martin
Certified CVI Developer
0 Kudos
Message 3 of 4
(4,240 Views)

Thank's so much!

 

All those years of C# development must have clouded my pointer-mind 😉

0 Kudos
Message 4 of 4
(4,236 Views)