Identification

  • Thread starter Thread starter Thom Little
  • Start date Start date
T

Thom Little

Are the following values available at execution time of a windows
application ...

- Date the module (assembly) was compiled.
- User Name specified during installation.
- Organization Name specified during installation.

What was the source of your information?
 
As for the latter two, I think the installer can store this information in
the registry. The Visual Studio Deployment Project AFAIR even contains a
pre-designed screen for entering the user name and the organization name. I
am not sure it provides an underlying framework for storing the data entered
though, but one could easily overcome this by creating a couple of registry
entries in the Registry Editor (I mean one of the Deployment Project editors
here, not regedit.exe) and specifying their values to be taken from the
properties associated with the "Name" and "Organization" text boxes on the
"Registration Information" screen.

As for the first one, I believe this can be retrieved as the last
modification date for any other file at the very least?
 
Thom,

Unless the person compiling decides to place the information in the
assembly (through attributes, resources, or some other mechanism), that
information is not available.

Hope this helps.
 
Thom said:
Are the following values available at execution time of a windows
application ...

- Date the module (assembly) was compiled.

If the assembly uses the default assembly-version-attribute, you can
calculate date/time from the last two entries in the version.

But the date/time of the file is in most cases also the compile/linkt time.
- User Name specified during installation. No.

- Organization Name specified during installation.
No.


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp


Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/
 
Do you have a snippet that shows how the last two parameters in the default
version are manipulated to proved the date/time of compilation ?
 
Thom said:
Do you have a snippet that shows how the last two parameters in the
default version are manipulated to proved the date/time of compilation

See: AssemblyVersionAttribute Constructor
http://msdn.microsoft.com/library/en-
us/cpref/html/frlrfsystemreflectionassemblyversionattributeclassctortopic.a
sp

<msdn>
The format of the version string is: major. minor. build. revision.

When specifying a version, you have to at least specify major. If you
specify major and minor, you can specify an asterisk (*) for build. This
will cause build to be equal to the number of days since January 1, 2000
local time, and for revision to be equal to the number of seconds since
midnight local time, divided by 2.

If you specify major, minor, and build, you can specify an asterisk for
revision. This will cause revision to be equal to the number of seconds
since midnight local time, divided by 2.
</msdn>


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
 
Thank you for the lead ...

I'm trying to learn how this all fits together. Do you know of any snippet
that shows how to capture these values during the install and have them
reflected as values in the Registry?

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Dmitriy Lapshin said:
As for the latter two, I think the installer can store this information in
the registry. The Visual Studio Deployment Project AFAIR even contains a
pre-designed screen for entering the user name and the organization name. I
am not sure it provides an underlying framework for storing the data entered
though, but one could easily overcome this by creating a couple of registry
entries in the Registry Editor (I mean one of the Deployment Project editors
here, not regedit.exe) and specifying their values to be taken from the
properties associated with the "Name" and "Organization" text boxes on the
"Registration Information" screen.

As for the first one, I believe this can be retrieved as the last
modification date for any other file at the very least?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Thom Little said:
Are the following values available at execution time of a windows
application ...

- Date the module (assembly) was compiled.
- User Name specified during installation.
- Organization Name specified during installation.

What was the source of your information?
 
It cannot be a snippet, since, to the best of my knowledge, it is just a
matter of correct Deployment Project configuration which does not require
coding. I would however suggest you reposted this question to the
microsoft.public.dotnet.framework.setup newsgroup to talk to Deployment
Project experts.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Thom Little said:
Thank you for the lead ...

I'm trying to learn how this all fits together. Do you know of any snippet
that shows how to capture these values during the install and have them
reflected as values in the Registry?

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Dmitriy Lapshin said:
As for the latter two, I think the installer can store this information in
the registry. The Visual Studio Deployment Project AFAIR even contains a
pre-designed screen for entering the user name and the organization
name.
I
am not sure it provides an underlying framework for storing the data entered
though, but one could easily overcome this by creating a couple of registry
entries in the Registry Editor (I mean one of the Deployment Project editors
here, not regedit.exe) and specifying their values to be taken from the
properties associated with the "Name" and "Organization" text boxes on the
"Registration Information" screen.

As for the first one, I believe this can be retrieved as the last
modification date for any other file at the very least?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Thom Little said:
Are the following values available at execution time of a windows
application ...

- Date the module (assembly) was compiled.
- User Name specified during installation.
- Organization Name specified during installation.

What was the source of your information?
 
Hi Thom,

Do you still have any concern on this issue? For your deployment concern, I
think some other group may be more suitable.

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
In the other newsgroup I was informed that it could be accomplished using
Orca.

To do this I have installed the Installation SDK and then installed Orca.

There is a dialog present in the .miss file that is used for this vary
purpose.

I can not determine how to modify the .miss file using Orca to enable this
action to occur.

The latest message on this subject appears to be a 180 degree reversal of
the previous course of action with a statement that it is "not an easy job"
to enable the behavior in question.

With regards to resolution ... your guess is as good as mine ... I guess I
don't know how to appropriately ask the question.
 
In my previous message .miss should have been .msi

Sorry.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Thom Little said:
In the other newsgroup I was informed that it could be accomplished using
Orca.

To do this I have installed the Installation SDK and then installed Orca.

There is a dialog present in the .miss file that is used for this vary
purpose.

I can not determine how to modify the .miss file using Orca to enable this
action to occur.

The latest message on this subject appears to be a 180 degree reversal of
the previous course of action with a statement that it is "not an easy job"
to enable the behavior in question.

With regards to resolution ... your guess is as good as mine ... I guess I
don't know how to appropriately ask the question.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

"Jeffrey Tan[MSFT]" said:
Hi Thom,

Do you still have any concern on this issue? For your deployment
concern,
I
think some other group may be more suitable.

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
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.
 
Sorry, there should be no dot after "Value = 123-1234567".

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.
 
Some of your responses precipitate more work when used. That was the case
with this one. Your approach is exactly what I needed and I now extract the
information from the installed program. This approach is now added to my
"toolbox" for use in other applications.

There is a lack of agreement on the term ProductID and Serial Number in the
documentation. Some references use one term and some use the other when
referring to the Product ID.

When testing, I set the Serial number (typed in serial number) in the
installer to a bogus value. This value is now being maintained through all
future installs and uninstalls. I would like to change or delete it.

How can I change or delete the Serial number that I entered darning setup?

Thanks again Felix. This thread has opened a whole new way that I think
about C# solutions that are "closer to" the operating system.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Felix Wang said:
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.
 
Hi Thom,

Thanks for your update. However, through Windows Installer APIs, we can
only read the user information of a product. We have no way to alter the
username, organization or PID after the installation via API. The user
information is supposed to be entered during the installation.

In addition, as far as I know, once we uninstall the product, the PID
should no longer be tracked. Could you elaborate a little bit more on "This
value is now being maintained through all future installs and uninstalls"?

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.
 
I Install the application.
In Customer Information I enter a serial number 777-7777777
It is accepted and the install continues.

I uninstall the application.

I install the application.
In Customer Information I enter a serial number 417-1000000
It presents an error dialog of ...
The key 417-1000000 is not valid. Verify you entered the correct key.
I respond OK
In Customer Information I enter a serial number 777-7777777
It is accepted and the install continues.

I want to change or delete the key that is being maintained on the machine
to which the install is being performed. (I need to have this capability as
a corrective measure if the customer enters a key and then forgets that they
entered and is prevented from installing the application.)
 
Felix:

You already replied to this issue in ...

microsoft.public.dotnet.framework.windowsforms

.... showing how to delete the Registry key.

Thank you.
 
Hi Thom,

I will reply you in "microsoft.public.dotnet.framework.windowsforms". You
may have some misunderstanding on the PID. It is not well documented:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/ht
ml/vxgrfserialnumbertemplateproperty.asp?frame=true

"For example, setting the SerialNumberTemplate property to "<### - %%%%>"
creates two text boxes separated by a dash surrounded by spaces. Validation
for the first box (###) simply verifies that the user has entered three
digits. The second box (%%%%) is validated by an algorithm that adds the
digits together and divides the sum by 7.If the remainder is 0, validation
succeeds; otherwise, it fails."

For any further issues, let's discuss them in the post under
"microsoft.public.dotnet.framework.windowsforms".

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.
 
Felix:

Your approach works perfectly with the three Windows XP machines on which I
installed it. It returns USERINFOSTATE_PRESENT.

Your approach does not work on either of two Windows 2000 machines on which
I installed it. It returns USERINFOSTATE_UNKNOWN.

Any ideas?

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Felix Wang said:
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.
 
Back
Top