Hi Thom,
You may try the Windows Installer API function to show the user name and
organization name of a installed product:
[DllImport("msi", CharSet=CharSet.Auto)]
public static extern USERINFOSTATE MsiGetUserInfo(
string szProduct, // product code, string GUID
string UserNameBuf, // return user name
ref int UserNameBufLen, // in/out buffer character count
string OrgNameBuf, // return company name
ref int OrgNameBufLen, // in/out buffer character count
string SerialBuf, // return product serial number
ref int SerialBufLen); // in/out buffer character count
// Obtain and store user info and PID from installation wizard (firstrun)
public enum USERINFOSTATE
{
USERINFOSTATE_MOREDATA = -3, // return buffer overflow
USERINFOSTATE_INVALIDARG = -2, // invalid function argument
USERINFOSTATE_UNKNOWN = -1, // unrecognized product
USERINFOSTATE_ABSENT = 0, // user info and PID not initialized
USERINFOSTATE_PRESENT = 1, // user info and PID initialized
};
To use the API:
string user = new string(new char[100]);
int userint = 100;
string org = new string(new char[100]);
int orgint = 100;
string serial = new string(new char[100]);
int serialint = 100;
USERINFOSTATE s = MsiGetUserInfo("{E05F0409-0E9A-48A1-AC04-E35E3033604A}",
user, ref userint, org, ref orgint, serial, ref serialint);
if (s == USERINFOSTATE.USERINFOSTATE_PRESENT)
{
Console.WriteLine(user.Substring(0, userint));
Console.WriteLine(org.Substring(0,orgint));
}
However, for the Setup project to register the user name and organization
name into the registry, the user must have a valid ProductID to validate:
RegisterUser Action
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/r
egisteruser_action.asp
As we can see, without a valid ProductID, the RegisterUser action will not
be execute.
We have 2 options here:
1. Change "ShowSerialNumber" property of the "Customer Information" dialog
to true. So the user has the option to input one product ID.
2. If we don't want the user to worry about the product ID, we can also use
Orca to input a default valid product ID into the "Property" table:
Property = PIDKEY
Value = 123-1234567.
I hope the information is useful to you.
Regards,
Felix Wang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.