07-24-2009 06:36 PM
Hi there,
Let me explain what I am doing.
In order to secure a program and ensure it can be only installed on a single computer; I read the MAC address of the PC, manipulate the MAC address to produce an Activation code. The user provides me thier MAC address and I provide them the Activation code for them to enter.
The issue is where to store the Activation code. I am using LV 8.0 and Vista but the software could be deployed to machines using XP or 2000. Previously I had decided to use the Windows registry to store the Activation code. However, I have since discovered that when I write to the registry in Vista the entry is nowhere to be found. I can read it ok but cannot find it. Where is it in Vista? A search of the registry won't locate it. I can find it in XP ok.
I need a reliable location to place the Activation code once users have entered it. I have seen suggestions of using the Windows API function ShGetKnownFolderPath (Vista) and ShGetFolder (XP, does it work for 2000?). These functions would enable me to do what?
How can I use the Windows API fnctions such as ShGetFolder? I have no idea.
Please help.
Thanks.
Solved! Go to Solution.
07-25-2009 01:32 AM
Hi battler.,
you can store the activation code near you application. Maybe in the ini file, which will automatically generate by the application.
Mike
07-25-2009 09:03 AM
Are you running as Administrator under Vista? I believe that Vista has restrictions on registry access (even reading) if you're not running as an admin. I think there's also the issue that even if you're logged in as an admin, Vista tries to run apps using a reduced set of permissions.
You should also be aware that LabVIEW 8.0 is not officially compatible with Vista. LabVIEW 8.2.1 was the first one to be marked as such by NI.
07-25-2009 04:58 PM - edited 07-25-2009 04:59 PM
Where in the registry did you try to write your key?
As smercurio said, under Vista access to the registry is quite different from XP. Even if you have administrative privileges, you can't write to HKEY_LOCAL_MACHINE (except when explicitely running an application with administrative privileges, like you do with an installer for instance). You can only read from there (to read, make sure you use read-only access when opening the registry key!).
You can write to HKEY_CURRENT_USER though.
Hope this helps,
Daniel
07-25-2009 05:11 PM
Continuation of last post...
Probably HKEY_CURRENT_USER will work for you. It's a bit difficult though when different Vista users use the application.
Be careful with Mike's suggestion. By default it's not possible to write to the Program Files folder (again, unless you run the application as admin or you grant full access to the folder/file to the user or the "Authenticated Users" group).
The application data folder might also be a good location to store it. To get the path you should use the Windows API to return the folder path. An implementation of this can be found on LAVA (post #7).
Hope this helps,
Daniel
07-25-2009 05:58 PM
I'm reading/writing to LOCAL MACHINE\Software in Vista. It seems to be working but I can't find the entry when I use VI registry functions. When I make registry entries as part of installer it works ok.
You say that I cannot write to the Programs folder. What about the applications folder, isn't that in the Programs folder? I suppose writing to the apps folder is a safer option.
07-26-2009 09:46 AM
This discussion if getting very confusing since it's also being discussed in the new thread.
Please pick a place.
07-27-2009 02:14 AM
battler. wrote:I'm reading/writing to LOCAL MACHINE\Software in Vista. It seems to be working but I can't find the entry when I use VI registry functions. When I make registry entries as part of installer it works ok.
Yes, during installation you can write to HKLM because the installer runs with admin rights. Do you open the key read-only when trying to read it?
battler. wrote:You say that I cannot write to the Programs folder. What about the applications folder, isn't that in the Programs folder? I suppose writing to the apps folder is a safer option.
The application data folder is NOT the program files folder.
In XP by default it is: C:\Documents and Settings\All Users\Application Data\<YOUR_APP>
In Vista: C:\ProgramData\<YOUR_APP>
But don't use these fixed paths, use the SHGetFolders (the VI I referred to in my last post does that for you).
07-28-2009 09:29 PM
All I know about are the program files folder and that seems to be where programs are installed.
Can't I use the VI location function to set a relative path to the installation folder?
I even tried joining LAVA to retrieve that ShGetFolder example; can't find it. It would seem the search function on LAVA is dismal compared to here. Let me know if you can help.
07-29-2009 02:14 AM
Here's the VI.
Use "COMMON_APPDATA" as CSIDL and append a folder for your application.