Hi Peter,
Sorry, I didn't post all the code here. Actually, my code is:
TCHAR szProductName[100] = {0};
DWORD length(0);
uiStatus =
MsiGetProductInfoW(szProductCode,L"InstalledProductName",L"",&length);
if(uiStatus == ERROR_MORE_DATA)
{
// TCHAR name[length+1];
uiStatus =
MsiGetProductInfoW(szProductCode,L"InstalledProductName",szProductName,&length);
}
Here uiStatus is always ERROR_MORE_DATA.
If I set DWORD length(50); It will break and have "access violation" error.
I want the way that Blair told me before, like:
uiStatus =
MsiGetProductInfoW(szProductCode,L"InstalledProductName",L"",&length);
if(uiStatus == ERROR_MORE_DATA)
{
length += 1; // We have to tell MsiGetProperty that the buffer has
space for the null terminator.
uiStatus =
MsiGetProductInfoW(szProductCode,L"InstalledProductName",CStrBufW(szProductName,
length, CStrBufW::SET_LENGTH),&length);
}
However, it must include header
#include <atlstr.h>
In my case, include atlstr.h will cause many errors, like:
1>D:\Program Files\Microsoft Visual Studio
8\VC\atlmfc\include\atlchecked.h(93) : error C2664: 'errno_t strcpy_s(char
*,rsize_t,const char *)' : cannot convert parameter 1 from 'TCHAR *' to 'char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast
Therefore, I don't know how to deal with this problem.
Could you please give me some hint?
Regards,
Chunyan
-----Ursprüngliche Nachricht-----
Von: Peter Shirtcliffe [mailto:[email protected]]
Gesendet: Donnerstag, 19. November 2009 17:35
An: General discussion for Windows Installer XML toolset.
Betreff: Re: [WiX-users] How to use MsiGetProductInfo function?
You are passing 0 as the size of the buffer in the "length" argument which is
too small.
Try
DWORD length = sizeof(szProductName)/sizeof(TCHAR);
-----Original Message-----
From: Jiang, Chunyan (GE Healthcare) [mailto:[email protected]]
Sent: 19 November 2009 16:12
To: General discussion for Windows Installer XML toolset.
Subject: [WiX-users] How to use MsiGetProductInfo function?
Hi,
I tried to retrieve some information about installed Product, as bellow:
TCHAR szProductName[100] = {0};
DWORD length(0);
MsiGetProductInfoW(szProductCode,L"InstalledProductName",szProductName,&
length);
However, it always return ERROR_MORE_DATA. It sounds like that TCHAR
szProductName[100] is not enough. Actually, length is only 42 in my case. I
would like to use
CStrBufW(szProductName, length, CStrBufW::SET_LENGTH)
instead of TCHAR. However, #include <atlstr.h> causes many errors, like:
1>D:\Program Files\Microsoft Visual Studio
8\VC\atlmfc\include\atlchecked.h(93) : error C2664: 'errno_t strcpy_s(char
*,rsize_t,const char *)' : cannot convert parameter 1 from 'TCHAR *' to 'char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast
Is there anyway to use MsiGetProductInfo function?
Regards,
Chunyan
------------------------------------------------------------------------
------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with Crystal
Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
SDL PLC confidential, all rights reserved.
If you are not the intended recipient of this mail SDL requests and requires
that you delete it without acting upon or copying any of its contents, and we
further request that you advise us.
SDL PLC is a public limited company registered in England and Wales.
Registered number: 02675207.
Registered address: Globe House, Clivemont Road, Maidenhead, Berkshire SL6 7DY,
UK.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with Crystal
Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-users