Unable to access ComputerID - Advanced Installer Community
fkus
Posts: 27
Joined: Fri Jan 04, 2019 7:38 pm

Unable to access ComputerID

Hello,

I'm having an issue accessing the ComputerID when the license is expired.

I have a custom registration window that I populate to supply the user with software information when asking them to register their license. It works great when the software is within the trial period, but once it exceeds said period my call to the ComputerID property returns a value of (5 or 13 - cannot recall which).

Is there a different method needed to acquire the ComputerID when the license is not registered? Or is there an additional step if the license registration fails in order to access the ComputerID?

Thanks for the help,
Francis

A previous thread I opened and discussed this issue

Code: Select all

public bool tryGetMachineID(out string machineID)
{
    return tryGetProperty(@"CompId", out machineID);
}

private bool tryGetProperty(string propertyId, out string property)
{
    var val = new StringBuilder();
    var len = (uint) val.Capacity;

    try
    {
        int result = (int) getProperty(propertyId, val, ref len);

        if (result != 0)
        {
            if (result == 234)
            {
                val.EnsureCapacity((int) len);
                getProperty(propertyId, val, ref len);
            }
            else
            {
                property = string.Empty;
                return false;
            }
        }

        property = val.ToString().Trim();
        return true;
    }
    catch (Exception)
    {
        property = string.Empty;
        return false;
    }
}

private static uint getProperty(string propertyName, StringBuilder val, ref uint len)
{
    return GetPropertyValue(propertyName, val, ref len);
}

[DllImport("Licensing.dll", EntryPoint = "GetPropertyValue", CharSet = CharSet.Unicode)]
private static extern uint GetPropertyValue(string aPropName, StringBuilder aResult, ref uint aResultLen);

//Initialize the registration - if no registration but trial is valid, place in trial mode
[DllImport("Licensing.dll", EntryPoint = "ReadSettingsRetStr", CharSet = CharSet.Ansi)]
private static extern uint InitTrial(string aKeyCode, IntPtr aHWnd);
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Unable to access ComputerID

Hello Francis,

I have answered the other forum thread of yours here:

viewtopic.php?f=2&t=36820&p=102992#p102992

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
fkus
Posts: 27
Joined: Fri Jan 04, 2019 7:38 pm

Re: Unable to access ComputerID

Hi Catalin,

Thanks for the response.

Francis
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: Unable to access ComputerID

You are always welcome, Francis.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”