HMGThinking-> Tuning HMG: Program Editor!
Posted: Sun Oct 16, 2016 10:59 pm
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://mail.hmgforum.com/
+1srvet_claudio wrote:HMGThinking is a web page with very interesting reflections, we could have here in the forum a section where links are grouped to this external pages.
Code: Select all
#include <hmg.ch>
Function Main
Local cEditor:=CheckExt("prg") // HKEY_CLASSES_ROOT\.PRG
Local cNPP:=""
If Empty(cEditor)
cNPP:=IsNotepadPlusPlus()
If !Empty(cNPP)
If MsgYesNo("Do you want to set Notepad++ as source default editor ?","Notepad++ is already installed")
cEditor:=cNPP
Endif
Endif
Endif
If Empty(cEditor)
MsgStop("Source editor <Not installed> !")
Else
MsgInfo(cEditor,"Editor for prg files")
Endif
Return Nil
Function CheckExt(cExt)
Local cRet, nIni, nFin
cRet := RegistryRead("HKEY_CLASSES_ROOT\."+cExt+"\")
If cRet=Nil
cRet:=""
Else
If !(":\" $ cRet)
cRet := RegistryRead("HKEY_CLASSES_ROOT\"+cRet+"\shell\open\command\")
Endif
Endif
If ":\" $ cRet
nIni:=HB_UAt('"',cRet)
nFin:=HB_UAt('"',HB_USubStr(cRet,nIni+1),2)
cRet:=HB_USubStr(cRet,nIni+1,nFin-1)
If !File(cRet)
cRet:=""
Endif
Endif
Return cRet
Function IsNotepadPlusPlus()
Local cRet:=""
cRet := RegistryRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Notepad++\UninstallString")
If !Empty(cRet)
If File(cRet)
cRet:=HB_USubStr(cRet,1,HB_UAt("\UNINSTALL.EXE",HMG_Upper(cRet)))+"notepad++.exe"
If !File(cRet)
cRet:=""
Endif
Else
cRet:=""
Endif
Endif
Return cRet