Man, that was hard. It seems like everything is though
DBP commands won't write to "HKEY_CLASSES_ROOT", only "HKEY_LOCAL_MACHINE". This cost me a lot of time, I couldn't figure out why it wasn't writing anything at all.
Quote: "One question though: Doesn't DBPro limit the registry commands so that you can only write to HKEY_LOCAL_MACHINE?"
I sure wish I'd seen that edit a long time ago
Then I found this handy little thread by MadrMan...
http://forum.thegamecreators.com/?m=forum_view&t=74495&b=1. That got me on the right track, but it took some heavy modifications. Each part must be passed to the registry exactly right or it either won't write or won't work, neither of which is very helpful. I was able to determine the exact strings needed by exporting other correct ones that matched the shell/command and DefaultIcon key values.
function RegisterFileType(ExtName as String, AppName as String)
RootKey$="HKEY_CLASSES_ROOT"
AppName=fixString(AppName)
writereg(RootKey$+"."+ExtName,"",ExtName+"file")
writereg(RootKey$+ExtName+"fileDefaultIcon","",Appname+",0")
writereg(RootKey$+ExtName+"fileshellopencommand","",""+chr$(34)+AppName+""+chr$(34)+" "+chr$(34)+"%1"+chr$(34))
load dll "shell32.dll",2
call dll 2,"SHChangeNotify","134217728","0","0","0"
delete dll 2
endfunction
function writereg(path$,key$,string$)
if file exist("c:/regwrite.reg") then delete file "c:/regwrite.reg"
open to write 1,"c:/regwrite.reg"
write string 1,"Windows Registry Editor Version 5.00"
write string 1,""
write string 1,"["+path$+"]"
if key$<>"" then write string 1,chr$(34)+key$+chr$(34)+"="+chr$(34)+string$+chr$(34)
if key$="" then write string 1,"@="+chr$(34)+string$+chr$(34)
close file 1
execute file "regedit.exe","/s c:/regwrite"+str$(file)+".reg","c:/windows/system32",1
wait 10
if file exist("c:regwrite.reg") then delete file "c:/regwrite.reg"
endfunction
function fixString(input$ as string)
for x=0 to len(input$)
if mid$(input$,x)=""
output$=output$+"\"
else
output$=output$+mid$(input$,x)
endif
next x
endfunction output$
This is a very clumsy way to do it, I'm going to combine it all into one single .reg file and execute it once. The purpose of this was just to get it working and to share portable code with everyone that might search for this in the future.
For anyone just joining this, this will associate a filetype with your application and change its icon to icon 0 in said application. This is the ugly DBP icon right now, I'll fix that for myself, you're all on your own.
This is how it's used...
Quote: "RegisterFileType("x", appname$())"
Use it wisely and sparingly!
Come see the WIP!