Inside the program I have a text box in which a user puts in the filepath to a textfile that the program then uses as a series of commands to perform tasks. This works perfectly, however what I would like to to do to make my program faster is associate the file extension .gam with the program, so when a user clicks a .gam file it opens the program and automatically sets said file's location into the text field, as opposed to using the browse button I added and browsing to said file everytime they run the program.
Through this a user could then make a shortcut to said .gam file and run it right from their desktop, as opposed to rummaging around in folders and whatnot.
At the moment my method has been thus, I have 2 folders of importance I have archived with the .exe, Gambits Pro.exe, these are: Gambits, and Control, inside of the Gambits folder is the default storage location for .gam files, as when you click the browse button its default directory is that folder. I have also added a few example files in said folder for a user when they download the program.
The program is meant to be standalone, and must be able to run from any directory. Thus what I decided to do was create a set up folder to set .gam files to reference the current location of the execute.
This is the control folder, inside is the set up executable and 2 icons for 2 different types of file types, .gam'ss and .mac's, what I wish to do is have these set of steps performed when the setup is run:
First, the program copys the 2 icons to System32, this part was easy and works fine.
Second, the program creates the registry key .gam and adds Gambit as a value, the set up for file association I believe. This also works fine.
Third, creates the set of subkeys Gambits\DefaultIcon and Gambits\Shell\open\command
Fourth, sets value of the default icon to the first icon I copied to system32, Gambit.ico
Fifth, takes the current directory of the running execute, and replaces \Control with Gambits Pro.exe, and sets that as the value of the \shell\open\command key, with of course " %1 " or whatever it is tied to the end, I don't even really know what that does but everything else has it so I assume its semi important. this tells the program to open .gam files with Gambits Pro.exe
Ok sweet it all seems to be set up, (I'll get to the other icon and extension later)
When I create a .gam file it has the proper icon and the program is the default opener.
But, when I click it, the stuff and messages that pop up in the programs initial loading sequence happen, but none of my forms pop up at all, its just a blank screen. When I look at running processes I see it on the list, but thats it.
I haven't even figured out yet how to set the file opened's path to the text box yet, and make it so that if a user opens the .exe manually it ignores that part of the script.
Second, I do pretty much the same process for .mac files, except instead of opening with gambits pro I want it to be opened in notepad by default. I set it to notepad but when I try and click it it gives me an access violation error message, says I dont have the right to do that, no option to even open as admin or anything.
So I right click -> open with -> notepad, and it works, but then the icon changes to a notepad file within a blank page, agh!
Worse yet, when I look at the registries, I don't see any registry pointing to said icon on the .mac stuff or Macro stuff that even lets me change it back, wtf?!
Here's my script I run, its pretty basic.
FileCopy(System.IO.Directory.GetCurrentDirectory() & "\Gambit.ico", "C:\Windows\System32\Gambit.ico")
My.Computer.Registry.ClassesRoot.CreateSubKey(".gam").SetValue("", "Gambit", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Gambit").SetValue("", "Gambit File", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Gambit\shell\open\command").SetValue("", System.IO.Directory.GetCurrentDirectory().Replace("Control", "Gambits Pro.exe"), Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey("Gambit\DefaultIcon").SetValue("", "%SystemRoot%\system32\Gambit.ico", Microsoft.Win32.RegistryValueKind.String)


Sign In
Create Account

Back to top









