LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

It seems a bug in CVI_AppGetProjectVersionInfo.

my platform: cvi6.0. windows xp. VC++6.0.
I'm calling CVI_AppGetProjectVersionInfo in my VC project. But all the values returned are 0xcccccccc, including MajorHi, MajorLo, MinorHi, MinorLo, Return_Value. And I noticed the Function Prototype in Function Help is :
HRESULT CVI_AppGetProjectVersionInfo (CAObjHandle Object_Handle,
ERRORINFO *Error_Info,
enum CVIEnum_CVIProjectVersionInfo Which,
char **Text,
long *Major_Hi,
long *Major_Lo,
long *Minor_Hi,
long *Minor_Lo,

long *Return_Value);
One of the parameter "char **Text" seems a little bit odd.
Is it a bug?

And CVI_AppSetProjectVersionInfo works fine.

BTW: my code snippet :
long MajorHi, MajorLo, MinorHi, MinorLo, Ret;

CVI_AppGetProjectVersionInfo (cviHandle, NULL,
CVIConst_CVI_PROJECT_VERSION_INFO_PRODUCT,
NULL, &MajorHi, &MajorLo, &MinorHi, &MinorLo, &Ret);

MajorHi = 2;
MajorLo = 0;
MinorHi = 0;
MinorLo = 0;
CVI_AppSetProjectVersionInfo (cviHandle, NULL,
CVIConst_CVI_PROJECT_VERSION_INFO_PRODUCT, "",
MajorHi, MajorLo, MinorHi, MinorLo, &Ret);
0 Kudos
Message 1 of 7
(3,179 Views)
CVI_AppGetProjectVersionInfo returns an error if the **text (version string) parameter is NULL. You can have the error info parameter NULL, but not the version string. See the function panel for CVI_AppGetProjectVersionInfo.
**text is not a bug. It's a pointer to a pointer (to a string). It's not uncommon to use that in C: the string space can be allocated by the called function and the new pointer returned to the calling routine.
0xCC is a clue: in Visual C++ debug builds, all memory is initialized to 0xCC. It's just an arbitrary value so the programmer can recognize whether the program wrote to memory as anticipated. See the VC++ help for the /GZ option.
Because your parameters return 0xCC, suspect an error in the CVI_AppGetProjectVersionInfo call. Don't i
gnore return errors. Do something like the following.
HRESULT error=0;
long cviError=0;
char *versionText;
...
error = CVI_AppGetProjectVersionInfo (cviHandle, NULL,
CVIConst_CVI_PROJECT_VERSION_INFO_PRODUCT,
&versionText, &MajorHi, &MajorLo, &MinorHi, &MinorLo, &cviError);
if (error < 0 || cviError < 0)
{
// report the error
}
Message 2 of 7
(3,179 Views)
Hi, Al S,
It works.
Thank you.

BTW, in the function panel help of **text (version string) parameter, it said:
"When it is no longer needed, you must the string returned in this parameter by calling the CVI ActiveX Library function CA_FreeMemory."
When I call CA_FreeMemory, a linking error occurs: "unresolved external symbol _CA_FreeMemory@4"
How to call CA_FreeMemory then? Should I add some library to my VC project?
0 Kudos
Message 3 of 7
(3,179 Views)
It's strange that you got a link error on CA_FreeMemory but not on CVI_AppGetProjectVersionInfo or CVI_AppSetProjectVersionInfo. They're all part of the same CVI ActiveX library.
Are cvisrvr.c and cvisrvr.fp included in your project?
Did you #include "cvisrvr.h" in the .c file from which you call CA_FreeMemory?
0 Kudos
Message 4 of 7
(3,179 Views)
CVI_AppGetProjectVersionInfo is in CVI ActiveX Automation Server, that is, in cvisrvr.fp. But CA_FreeMemory is in ActiveX Library, I can't find it in cvisrvr.fp. I don't know which file I should include.

I generate cvisrvr.dll/lib from cvisrvr.c and include them in my project.

Thanks.

Echo
0 Kudos
Message 5 of 7
(3,179 Views)
You're right about CVI_AppGetProjectVersionInfo vs. CA_FreeMemory.
I forgot you're using VC++. If you're using CVI, you just have to include cvisrvr.h or cviauto.h (also included by cvisrvr.h) to get the ActiveX library. But in VC++, you need to add ..\cvi\extlib\cviauto.lib to your project. See the CVI help topic Using CVI Libraries in External Compilers.
0 Kudos
Message 6 of 7
(3,179 Views)
Thanks a lot!

Echo
0 Kudos
Message 7 of 7
(3,179 Views)