Posts: 38
Threads: 3
Joined: Apr 2022
Reputation:
3
06-05-2022, 03:51 PM
(This post was last modified: 06-05-2022, 03:53 PM by euklides.)
I'm looking for a way to read a single value from the registry (Win).
This exemple lists recents files opened in CorelDRAW Home & Student
Program written in VBA Excel.
Is it possible to have something same in QB64 ???
Thank's for help.
'---VBA EXCEL PROG---
a$ = "HKEY_CURRENT_USER\Software\Corel\CorelDRAW Home & Student\18.0\PPHome\Application Preferences\Framework\RecentFiles"
MsgBox RegKeyRead(a$)
stop
'---
Function RegKeyRead(i_RegKey As String) As String
Dim myWS As Object
On Error Resume Next
Set myWS = CreateObject("WScript.Shell")
RegKeyRead = myWS.RegRead(i_RegKey)
End Function
'---
Why not yes ?
Posts: 38
Threads: 3
Joined: Apr 2022
Reputation:
3
06-06-2022, 02:41 PM
(This post was last modified: 06-06-2022, 02:48 PM by euklides.)
Now, a solution...
Reading a information from the Windows Registrer
QA$ = "HKEY_CURRENT_USER\Software\Corel\CorelDRAW Home & Student\18.0\PPHome\Application Preferences\Framework\RecentFiles"
(here I want to get the list of last opened files in CorelDRAW Home & Student)
Of course you can change with an other information from Register (use Regedit to select it)
This little program does not Write, only read, in the Register:
QA$ = "HKEY_CURRENT_USER\Software\Corel\CorelDRAW Home & Student\18.0\PPHome\Application Preferences\Framework\RecentFiles"
AB$ = RegisterRead$(QA$)
Print "--->"; AB$; "<--": Sleep
stop
Function RegisterRead$ (QA$)
FS2$ = Chr$(13) + Chr$(10):
fs1$ = "Dim WSCRA" + FS2$ + "On Error Resume Next" + FS2$ + "Set WSCRA = CreateObject(²WScript.Shell²)" + FS2$
fs1$ = fs1$ + "RegKeyRead = WSCRA.RegRead(²" + QA$ + "²)" + FS2$
fs1$ = fs1$ + "Set WSCRI = CreateObject(²Scripting.FileSystemObject²).OpenTextFile(²Temp_result.txt²,2,true)" + FS2$
fs1$ = fs1$ + "WSCRI.WriteLine(RegKeyRead)" + FS2$ + "WSCRI.Close" + FS2$ + "Set WSCRI = Nothing" + FS2$
fs1$ = fs1$ + "Set Wshell=nothing" + FS2$ + "Set WSCRA=nothing" + FS2$ + "On error goto 0":
fsU: J = InStr(fs1$, "²"): If J > 0 Then Mid$(fs1$, J, 1) = Chr$(34): GoTo fsU
ficvbs$ = _CWD$ + "\TEMP_FS.vbs": channel% = FreeFile: Open ficvbs$ For Output As channel%
Print #1, fs1$: Close channel%
_Delay 0.1: Shell "cscript //NoLogo " + ficvbs$: _Delay .2: Kill ficvbs$
ficdon$ = _CWD$ + "\TEMP_RESULT.TXT": channel% = FreeFile: Open ficdon$ For Input As channel%
YY$ = "": While Not EOF(channel%): Line Input #channel%, DDD$: YY$ = YY$ + DDD$ + FS2$
Wend: Close channel%: Kill ficdon$
RegisterRead$ = Left$(YY$, Len(YY$) - 2)
End Function
Why not yes ?