-
Notifications
You must be signed in to change notification settings - Fork 4
/
settingsModule.bas
1125 lines (1059 loc) · 44.1 KB
/
settingsModule.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Attribute VB_Name = "Module1"
Option Explicit
'
'Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'
'Public debugflg As Integer
'Public toolSettingsFile As String
'
'Public Declare Sub Sleep Lib "Kernel32.dll" (ByVal dwMilliseconds As Long)
'Private Declare Function EnumProcesses Lib "psapi.dll" (lpidProcess As Long, ByVal cb As Long, cbNeeded As Long) As Long
'Private Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long
'Private Declare Function GetModuleBaseName Lib "psapi.dll" Alias "GetModuleBaseNameA" (ByVal hProcess As Long, ByVal hmodule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
'Private Declare Function QueryFullProcessImageName Lib "Kernel32.dll" Alias "QueryFullProcessImageNameA" (ByVal hProcess As Long, ByVal dwFlags As Long, ByVal lpExeName As String, lpdwSize As Long) As Long
'Private Const PROCESS_VM_READ = &H10
'Private Const PROCESS_QUERY_INFORMATION = &H400
' declare global arrays to make the settings data open to everyone
' they are declmnuOtherOptsared but undimensioned as we need to declare them with
' a size controlled by the rdIconMax variable above, that is done
' during the form_load when the rdIconMax value is defined
'Public sFilename As String
'Public sFileName2 As String
'Public sTitle As String
'Public sCommand As String
'Public sArguments As String
'Public sWorkingDirectory As String
'Public sShowCmd As String
'Public sOpenRunning As String
'Public sIsSeparator As String
'Public sUseContext As String
'Public sDockletFile As String
'Public rdSettingsFile As String
'Public usedMenuFlag As Boolean
'
''API Function to read information from INI File
'Public Declare Function GetPrivateProfileString Lib "kernel32" _
' Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any _
' , ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long _
' , ByVal lpFileName As String) As Long
'
''API Function to write information to the INI File
'Private Declare Function WritePrivateProfileString Lib "kernel32" _
' Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any _
' , ByVal lpString As Any, ByVal lpFileName As String) As Long
'Public Const HKEY_LOCAL_MACHINE = &H80000002
'Public Const HKEY_CURRENT_USER = &H80000001
'Public Const REG_SZ = 1 ' Unicode nul terminated string
'
'' main APIs, constants defined for querying the registry
'' some global variables and a few local subroutines/functions
'' pertaining to the main form.
'
'Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByRef phkResult As Long) As Long
'Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByRef lpData As Any, ByRef lpcbData As Long) As Long
'Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
'Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByRef phkResult As Long) As Long
'Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByRef lpData As Any, ByVal cbData As Long) As Long
'' functions to determine 64bitness start
'Private Declare Function GetProcAddress Lib "kernel32" _
' (ByVal hmodule As Long, _
' ByVal lpProcName As String) As Long
'
'Private Declare Function GetModuleHandle Lib "kernel32" _
' Alias "GetModuleHandleA" _
' (ByVal lpModuleName As String) As Long
'
''Private Declare Function GetCurrentProcess Lib "kernel32" _
'' () As Long 'already declared
'
'Private Declare Function IsWow64Process Lib "kernel32" _
' (ByVal hProc As Long, _
' bWow64Process As Boolean) As Long
'' functions to determine 64bitness END
'Public WindowsVer As String
'Public requiresAdmin As Boolean
'Public rdAppPath As String
'Public origSettingsFile As String
'Public rdIconMaximum As Integer
'Public theCount As Integer
'Public dockOpacity As Integer
'Public userLevel As String
'Public namesListArray() As String
'Public sCommandArray() As String
'Public autoHideTimerCount As Integer
'Public animationFlg As Boolean
'Public dockLoweredTime As Date
'Public dockHidden As Boolean
'
'Public rocketDockInstalled As Boolean
'Public RDinstalled As String
'Public RD86installed As String
'Public RDregistryPresent As Boolean
'
'Public dockSettingsFile As String
'
'Public rDRunAppInterval As String
'Public rDAlwaysAsk As String
'Public rDGeneralReadConfig As String
'Public rDGeneralWriteConfig As String
'
'Public rDSkinTheme As String
'Public rDDefaultDock As String
'
'
'
'Public lngBitmap As Long
'Public lngImage As Long
'Public lngGDI As Long
'Public lngReturn As Long
'Public Declare Function GetModuleFileNameExA Lib "psapi.dll" ( _
' ByVal hProcess As Long, ByVal hmodule As Long, _
' ByVal moduleName As String, ByVal nSize As Long) As Long
'
''---------------------------------------------------------------------------------------
'' Procedure : LoadFileToTB
'' Author : beededea
'' Date : 26/08/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Public Function LoadFileToTB(TxtBox As Object, FilePath As _
' String, Optional Append As Boolean = False) As Boolean
'
' 'PURPOSE: Loads file specified by FilePath into textcontrol
' '(e.g., Text Box, Rich Text Box) specified by TxtBox
'
' 'If Append = true, then loaded text is appended to existing
' ' contents else existing contents are overwritten
'
' 'Returns: True if Successful, false otherwise
'
' Dim iFile As Integer
' Dim s As String
'
' On Error GoTo LoadFileToTB_Error
' If debugflg = 1 Then DebugPrint "%" & "LoadFileToTB"
'
'
' If debugflg = 1 Then DebugPrint "%" & LoadFileToTB
'
' If Dir$(FilePath) = vbNullString Then Exit Function
'
' On Error GoTo ErrorHandler:
' s = TxtBox.Text
'
' iFile = FreeFile
' Open FilePath For Input As #iFile
' s = Input(LOF(iFile), #iFile)
' If Append Then
' TxtBox.Text = TxtBox.Text & s
' Else
' TxtBox.Text = s
' End If
'
' LoadFileToTB = True
'
'ErrorHandler:
' If iFile > 0 Then Close #iFile
'
' On Error GoTo 0
' Exit Function
'
'LoadFileToTB_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure LoadFileToTB of Form dock"
'
'End Function
''
''---------------------------------------------------------------------------------------
'' Procedure : GetINISetting
'' Author : beededea
'' Date : 05/07/2019
'' Purpose : Get the INI Setting from the File
''---------------------------------------------------------------------------------------
''
'Public Function GetINISetting(ByVal sHeading As String, ByVal sKey As String, ByRef sINIFileName As String) As String
' On Error GoTo GetINISetting_Error
' Const cparmLen = 500 ' maximum no of characters allowed in the returned string
' Dim sReturn As String * cparmLen
' Dim sDefault As String * cparmLen
' Dim lLength As Long
'
' lLength = GetPrivateProfileString(sHeading, sKey, sDefault, sReturn, cparmLen, sINIFileName)
' GetINISetting = Mid(sReturn, 1, lLength)
'
' On Error GoTo 0
' Exit Function
'
'GetINISetting_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure GetINISetting of Module Module2"
'End Function
''
''---------------------------------------------------------------------------------------
'' Procedure : PutINISetting
'' Author : beededea
'' Date : 05/07/2019
'' Purpose : Save INI Setting in the File
''---------------------------------------------------------------------------------------
''
'Public Sub PutINISetting(ByVal sHeading As String, ByVal sKey As String, ByVal sSetting As String, ByRef sINIFileName As String)
'
' On Error GoTo PutINISetting_Error
'
' Dim aLength As Long
'
' aLength = WritePrivateProfileString(sHeading, sKey _
' , sSetting, sINIFileName)
'
' On Error GoTo 0
' Exit Sub
'
'PutINISetting_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure PutINISetting of Module Module2"
'End Sub
'
''---------------------------------------------------------------------------------------
'' Procedure : readIconSettingsIni
'' Author : beededea
'' Date : 21/09/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Public Sub readIconSettingsIni(location As String, ByVal iconNumberToRead As Integer, settingsFile As String)
' 'Reads an .INI File (SETTINGS.INI)
'
' On Error GoTo readIconSettingsIni_Error
' If debugflg = 1 Then DebugPrint "%readIconSettingsIni"
' '"Software\RocketDock\Icons"
' sFilename = GetINISetting(location, iconNumberToRead & "-FileName", settingsFile)
' sFileName2 = GetINISetting(location, iconNumberToRead & "-FileName2", settingsFile)
' sTitle = GetINISetting(location, iconNumberToRead & "-Title", settingsFile)
' sCommand = GetINISetting(location, iconNumberToRead & "-Command", settingsFile)
' sArguments = GetINISetting(location, iconNumberToRead & "-Arguments", settingsFile)
' sWorkingDirectory = GetINISetting(location, iconNumberToRead & "-WorkingDirectory", settingsFile)
' sShowCmd = GetINISetting(location, iconNumberToRead & "-ShowCmd", settingsFile)
' sOpenRunning = GetINISetting(location, iconNumberToRead & "-OpenRunning", settingsFile)
' sIsSeparator = GetINISetting(location, iconNumberToRead & "-IsSeparator", settingsFile)
' sUseContext = GetINISetting(location, iconNumberToRead & "-UseContext", settingsFile)
' sDockletFile = GetINISetting(location, iconNumberToRead & "-DockletFile", settingsFile)
'
' On Error GoTo 0
' Exit Sub
'
'readIconSettingsIni_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure readIconSettingsIni of Module Module2"
'End Sub
'
''---------------------------------------------------------------------------------------
'' Procedure : writeIconSettingsIni
'' Author : beededea
'' Date : 21/09/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
''Public Sub writeIconSettingsIni(ByVal iconNumberToWrite As Integer)
'Sub writeIconSettingsIni(location As String, ByVal iconNumberToWrite As Integer, settingsFile As String)
'
' 'Writes an .INI File (SETTINGS.INI)
'
' 'E:\Program Files (x86)\RocketDock\Icons\Steampunk_Clockwerk_Kubrick
' ' determine relative path TODO
' ' Icons\Steampunk_Clockwerk_Kubrick
'
' On Error GoTo writeIconSettingsIni_Error
' If debugflg = 1 Then DebugPrint "%writeIconSettingsIni"
'
' PutINISetting location, iconNumberToWrite & "-FileName", sFilename, settingsFile
' PutINISetting location, iconNumberToWrite & "-FileName2", sFileName2, settingsFile
' PutINISetting location, iconNumberToWrite & "-Title", sTitle, settingsFile
' PutINISetting location, iconNumberToWrite & "-Command", sCommand, settingsFile
' PutINISetting location, iconNumberToWrite & "-Arguments", sArguments, settingsFile
' PutINISetting location, iconNumberToWrite & "-WorkingDirectory", sWorkingDirectory, settingsFile
' PutINISetting location, iconNumberToWrite & "-ShowCmd", sShowCmd, settingsFile
' PutINISetting location, iconNumberToWrite & "-OpenRunning", sOpenRunning, settingsFile
' PutINISetting location, iconNumberToWrite & "-IsSeparator", sIsSeparator, settingsFile
' PutINISetting location, iconNumberToWrite & "-UseContext", sUseContext, settingsFile
' PutINISetting location, iconNumberToWrite & "-DockletFile", sDockletFile, settingsFile
'
' On Error GoTo 0
' Exit Sub
'
'writeIconSettingsIni_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure writeIconSettingsIni of Module Module2"
'
'End Sub
''---------------------------------------------------------------------------------------
'' Procedure : removeSettingsIni
'' Author : beededea
'' Date : 21/09/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Public Sub removeSettingsIni(ByVal iconNumberToWrite As Integer)
'
' 'removes data from the ini file at the given location
'
' On Error GoTo removeSettingsIni_Error
' If debugflg = 1 Then DebugPrint "%removeSettingsIni"
'
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-FileName", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-FileName2", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-Title", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-Command", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-Arguments", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-WorkingDirectory", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-ShowCmd", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-OpenRunning", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-IsSeparator", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-UseContext", vbNullString, rdSettingsFile
' PutINISetting "Software\RocketDock\Icons", iconNumberToWrite & "-DockletFile", vbNullString, rdSettingsFile
'
' On Error GoTo 0
' Exit Sub
'
'removeSettingsIni_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure removeSettingsIni of Module Module2"
'
'End Sub
''----------------------------------------
''Name: TestWinVer
''Description:
''----------------------------------------
'Public Sub testWinVer()
'
' Dim ProgramFilesDir As String
' Dim classicThemeCapable As Boolean
'
' '=================================
' '2000 / XP / NT / 7 / 8 / 10
' '=================================
' On Error GoTo TestWinVer_Error
'
' If debugflg = 1 Then DebugPrint "%" & "TestWinVer"
'
' On Error Resume Next
' Dim strString As String
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName")
' WindowsVer = strString
'
' ' note that when running in compatibility mode the o/s will always respond with "Windows XP"
' ' The IDE runs in compatibility mode so it will report the wrong working folder
'
' 'MsgBox WindowsVer
'
' 'Get the value of "ProgramFiles", or "ProgramFilesDir"
'
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
' classicThemeCapable = False
' requiresAdmin = False
'
' If InStr(WindowsVer, "Windows NT4") <> 0 Then
' classicThemeCapable = True
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' End If
' If InStr(WindowsVer, "Windows 2000") <> 0 Then
' classicThemeCapable = True
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' End If
' If InStr(WindowsVer, "Windows XP") <> 0 Then
' classicThemeCapable = True
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
' End If
' If InStr(WindowsVer, "Windows 2003") <> 0 Then
' classicThemeCapable = True
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' End If
' If InStr(WindowsVer, "Windows Vista") <> 0 Then
' classicThemeCapable = True
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' requiresAdmin = True
' End If
' If InStr(WindowsVer, "Windows 7") <> 0 Then
' classicThemeCapable = True
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' requiresAdmin = True
' 'MsgBox "%" & "WindowsVer = " & windowsVer & " strString = " & strString
' End If
' If InStr(WindowsVer, "Windows 2008") <> 0 Then
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' End If
' If InStr(WindowsVer, "Windows 8") <> 0 Then
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' requiresAdmin = True
' End If
' If InStr(WindowsVer, "Windows 2012") <> 0 Then
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' requiresAdmin = True
' End If
' If InStr(WindowsVer, "Windows 10") <> 0 Then
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' requiresAdmin = True
' End If
' If InStr(WindowsVer, "Windows 2016") <> 0 Then
' strString = getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProgramFilesDir")
' requiresAdmin = True
' End If
'
' If debugflg = 1 Then DebugPrint "%" & "WindowsVer = " & WindowsVer
'
' ProgramFilesDir = strString
' If ProgramFilesDir = vbNullString Then ProgramFilesDir = "c:\program files (x86)" ' 64bit systems use this
' If Not DirExists(ProgramFilesDir) Then
' ProgramFilesDir = "c:\program files" ' 32 bit systems use this
' End If
'
' If debugflg = 1 Then DebugPrint "%" & "ProgramFilesDir = " & ProgramFilesDir
'
' 'MsgBox "%" & "WindowsVer = " & windowsVer & " " & ProgramFilesDir
'
' '======================================================
' 'END routine error handler
' '======================================================
'
'
' On Error GoTo 0: Exit Sub
'
'TestWinVer_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure TestWinVer of Module WinModule"
'
'End Sub
''---------------------------------------------------------------------------------------
'' Procedure : getstring
'' Author : beededea
'' Date : 05/07/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Public Function getstring(ByRef hKey As Long, ByRef strPath As String, ByRef strvalue As String) As String
'
' Dim keyhand As Long
' 'Dim datatype As Long
' Dim lResult As Long
' Dim strBuf As String
' Dim lDataBufSize As Long
' Dim intZeroPos As Integer
' Dim rvar As Integer
' 'in .NET the variant type will need to be replaced by object?
'
' Dim lValueType As Variant
'
' On Error GoTo getstring_Error
'
' rvar = RegOpenKey(hKey, strPath, keyhand)
' lResult = RegQueryValueEx(keyhand, strvalue, 0&, lValueType, ByVal 0&, lDataBufSize)
' If lValueType = REG_SZ Then
' strBuf = String$(lDataBufSize, " ")
' lResult = RegQueryValueEx(keyhand, strvalue, 0&, 0&, ByVal strBuf, lDataBufSize)
' Dim ERROR_SUCCESS As Variant
' If lResult = ERROR_SUCCESS Then
' intZeroPos = InStr(strBuf, Chr$(0))
' If intZeroPos > 0 Then
' getstring = Left$(strBuf, intZeroPos - 1)
' Else
' getstring = strBuf
' End If
' End If
' End If
'
' On Error GoTo 0
' Exit Function
'
'getstring_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure getstring of Module Module1"
'End Function
'
''---------------------------------------------------------------------------------------
'' Procedure : savestring
'' Author : beededea
'' Date : 05/07/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Public Sub savestring(ByRef hKey As Long, ByRef strPath As String, ByRef strvalue As String, ByRef strData As String)
'
' Dim keyhand As Long
' Dim R As Long
' On Error GoTo savestring_Error
'
' R = RegCreateKey(hKey, strPath, keyhand)
' R = RegSetValueEx(keyhand, strvalue, 0, REG_SZ, ByVal strData, Len(strData))
' R = RegCloseKey(keyhand)
'
' On Error GoTo 0
' Exit Sub
'
'savestring_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure savestring of Module Module1"
'End Sub
''---------------------------------------------------------------------------------------
'' Procedure : checkRocketdockInstallation
'' Author : beededea
'' Date : 20/06/2019
'' Purpose : we check to see if rocketdock is installed in order to know the location of the settings.ini file used by Rocketdock
'' *** also sets rdAppPath during the drivecheck ***
''---------------------------------------------------------------------------------------
'
'Public Sub checkRocketdockInstallation()
' RD86installed = vbNullString
' RDinstalled = vbNullString
'
' ' check where rocketdock is installed
' On Error GoTo checkRocketdockInstallation_Error
' If debugflg = 1 Then DebugPrint "%" & "checkRocketdockInstallation"
'
' RD86installed = driveCheck("Program Files (x86)\Rocketdock", "RocketDock.exe")
' RDinstalled = driveCheck("Program Files\Rocketdock", "RocketDock.exe")
'
' If RDinstalled = vbNullString And RD86installed = vbNullString Then
' rocketDockInstalled = False
' Else
' rocketDockInstalled = True
' If RDinstalled <> vbNullString Then
' rdAppPath = RDinstalled
' End If
' 'the one in the x86 folder has precedence
' If RD86installed <> vbNullString Then
' rdAppPath = RD86installed
' End If
' End If
'
' ' If rocketdock Is Not installed Then test the registry
' ' if the registry settings are not located then remove them as a source.
'
' ' you might think this stuff is better placed in the docksettings utility
' ' but it has to be here as well as SteamyDock is the component that is most likely to br run first.
'
' ' rocketDockInstalled = False ' debug
'
' ' read selected random entries from the registry, if each are false then the RD registry entries do not exist.
' If rocketDockInstalled = False Then
' rDLockIcons = getstring(HKEY_CURRENT_USER, "Software\RocketDock\", "LockIconsd")
' rDOpenRunning = getstring(HKEY_CURRENT_USER, "Software\RocketDock\", "OpenRunnings")
' rDShowRunning = getstring(HKEY_CURRENT_USER, "Software\RocketDock\", "ShowRunnings")
' rDManageWindows = getstring(HKEY_CURRENT_USER, "Software\RocketDock\", "ManageWindowsw")
' rDDisableMinAnimation = getstring(HKEY_CURRENT_USER, "Software\RocketDock\", "DisableMinAnimations")
' If rDLockIcons = vbNullString And rDOpenRunning = vbNullString And rDShowRunning = vbNullString And rDManageWindows = vbNullString And rDDisableMinAnimation = vbNullString Then
' ' rocketdock registry entries do not exist so RD has never been installed or it has been wiped entirely.
' RDregistryPresent = False
' Else
' RDregistryPresent = True 'rocketdock HAS been installed in the past as the registry entries are still present
' End If
' End If
'
' On Error GoTo 0
' Exit Sub
'
'checkRocketdockInstallation_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure checkRocketdockInstallation of Form dock"
'End Sub
'
''---------------------------------------------------------------------------------------
'' Procedure : driveCheck
'' Author : beededea
'' Date : 20/06/2019
'' Purpose : check for the existence of the rocketdock binary
''---------------------------------------------------------------------------------------
''
'Public Function driveCheck(ByVal folder As String, filename As String) As String
' Dim sAllDrives As String
' Dim sDrv As String
' Dim sDrives() As String
' Dim cnt As Long
' Dim folderString As String
' Dim testAppPath As String
'
' 'get the list of all drives
' On Error GoTo driveCheck_Error
' If debugflg = 1 Then DebugPrint "%" & "driveCheck"
'
' sAllDrives = GetDriveString()
'
' 'Change nulls to spaces, then trim.
' 'This is required as using Split()
' 'with Chr$(0) alone adds two additional
' 'entries to the array drives at the end
' 'representing the terminating characters.
' sAllDrives = Replace$(sAllDrives, Chr$(0), Chr$(32))
' sDrives() = Split(Trim$(sAllDrives), Chr$(32))
'
' For cnt = LBound(sDrives) To UBound(sDrives)
' sDrv = sDrives(cnt)
' ' on 32bit windows the folder is "Program Files\Rocketdock"
' folderString = sDrv & folder
' If DirExists(folderString) = True Then
' 'test for the Rocketdock binary
' testAppPath = folderString
' If FExists(testAppPath & "\" & filename) Then
' 'MsgBox "Rocketdock binary exists"
' driveCheck = testAppPath
' Exit Function
' End If
' End If
' Next
'
' On Error GoTo 0
' Exit Function
'
'driveCheck_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure driveCheck of Form dock"
'
'End Function
''---------------------------------------------------------------------------------------
'' Procedure : GetDriveString
'' Author : beededea
'' Date : 20/06/2019
'' Purpose : Determine the number and name of drives using VB alone
''---------------------------------------------------------------------------------------
''
'Private Function GetDriveString() As String
'
' 'Used by both demos
'
' ' returns string of available
' ' drives each separated by a null
' ' Dim sBuff As String
' '
' ' possible 26 drives, three characters
' ' each plus a trailing null for each
' ' drive letter and a terminating null
' ' for the string
'
' Dim I As Long
' Dim builtString As String
'
' '===========================
' 'pure VB approach, no controls required Gary Beene
' 'drive letters are found in positions 1-UBound(Letters)
' '"C:\ D:\ E:\ &frameProperties"
'
' On Error GoTo GetDriveString_Error
' If debugflg = 1 Then DebugPrint "%" & "GetDriveString"
'
'
'
' For I = 1 To 26
' If ValidDrive(Chr$(96 + I)) = True Then
' builtString = builtString + UCase$(Chr$(96 + I)) & ":\ "
' End If
' Next I
'
' GetDriveString = builtString
'
' On Error GoTo 0
' Exit Function
'
'GetDriveString_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure GetDriveString of Form dock"
'End Function
''---------------------------------------------------------------------------------------
'' Procedure : ValidDrive
'' Author : beededea
'' Date : 20/06/2019
'' Purpose : Check if the drive found is a valid one
''---------------------------------------------------------------------------------------
''
'Public Function ValidDrive(ByVal d As String) As Boolean
' On Error GoTo ValidDrive_Error
' If debugflg = 1 Then DebugPrint "%" & "ValidDrive"
' On Error GoTo driveerror
' Dim Temp As String
'
' Temp = CurDir$
' ChDrive d
'
' ChDir Temp
' ValidDrive = True
'
' Exit Function
'driveerror:
'
' On Error GoTo 0
' Exit Function
'
'ValidDrive_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ValidDrive of Form dock"
'End Function
''---------------------------------------------------------------------------------------
'' Procedure : readIconRegistryWriteSettings
'' Author : beededea
'' Date : 20/06/2019
'' Purpose : Read the registry one line at a time and create a temporary settings file
''---------------------------------------------------------------------------------------
''
'Private Sub readIconRegistryWriteSettings(settingsFile As String)
' Dim useloop As Integer
'
' On Error GoTo readIconRegistryWriteSettings_Error
' If debugflg = 1 Then DebugPrint "%" & "readIconRegistryWriteSettings"
'
' For useloop = 0 To rdIconMaximum
' ' get the relevant entries from the registry
' readRegistryOnce (useloop)
' ' write the rocketdock alternative settings.ini
' Call writeIconSettingsIni("Software\RocketDock\Icons", useloop, settingsFile) ' the alternative settings.ini exists when RD is set to use it
' Next useloop
'
' On Error GoTo 0
' Exit Sub
'
'readIconRegistryWriteSettings_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure readIconRegistryWriteSettings of Form dock"
'End Sub
'
''---------------------------------------------------------------------------------------
'' Procedure : readRegistryOnce
'' Author : beededea
'' Date : 20/06/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Private Sub readRegistryOnce(ByVal iconNumberToRead As Integer)
' ' read the settings from the registry
' On Error GoTo readRegistryOnce_Error
' If debugflg = 1 Then DebugPrint "%" & "readRegistryOnce"
'
' sFilename = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-FileName")
' sFileName2 = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-FileName2")
' sTitle = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-Title")
' sCommand = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-Command")
' sArguments = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-Arguments")
' sWorkingDirectory = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-WorkingDirectory")
' sShowCmd = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-ShowCmd")
' sOpenRunning = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-OpenRunning")
' sIsSeparator = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-IsSeparator")
' sUseContext = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-UseContext")
' sDockletFile = getstring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToRead & "-DockletFile")
'
' On Error GoTo 0
' Exit Sub
'
'readRegistryOnce_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure readRegistryOnce of Form dock"
'
'End Sub
''---------------------------------------------------------------------------------------
'' Procedure : writeRegistryOnce
'' Author : beededea
'' Date : 20/06/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Private Sub writeRegistryOnce(ByVal iconNumberToWrite As Integer)
'
' On Error GoTo writeRegistryOnce_Error
' If debugflg = 1 Then DebugPrint "%" & "writeRegistryOnce"
'
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-FileName", sFilename)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-FileName2", sFileName2)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-Title", sTitle)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-Command", sCommand)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-Arguments", sArguments)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-WorkingDirectory", sWorkingDirectory)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-ShowCmd", sShowCmd)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-OpenRunning", sOpenRunning)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-IsSeparator", sIsSeparator)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-UseContext", sUseContext)
' Call savestring(HKEY_CURRENT_USER, "Software\RocketDock\Icons", iconNumberToWrite & "-DockletFile", sDockletFile)
'
' On Error GoTo 0
' Exit Sub
'
'writeRegistryOnce_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure writeRegistryOnce of Form dock"
'End Sub
''---------------------------------------------------------------------------------------
'' Procedure : ExtractSuffixWithDot
'' Author : beededea
'' Date : 20/06/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Public Function ExtractSuffixWithDot(ByVal strPath As String) As String
' Dim AY() As String ' string array
' Dim Max As Integer
'
' On Error GoTo ExtractSuffixWithDot_Error
' If debugflg = 1 Then DebugPrint "%" & "ExtractSuffixWithDot"
'
' If strPath = vbNullString Then
' ExtractSuffixWithDot = vbNullString
' Exit Function
' End If
'
' If InStr(strPath, ".") <> 0 Then
' AY = Split(strPath, ".")
' Max = UBound(AY)
' ExtractSuffixWithDot = "." & AY(Max)
' Else
' ExtractSuffixWithDot = strPath
' End If
'
' On Error GoTo 0
' Exit Function
'
'ExtractSuffixWithDot_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExtractSuffixWithDot of Form dock"
'End Function
'
'
''---------------------------------------------------------------------------------------
'' Procedure : ExtractSuffix
'' Author : beededea
'' Date : 20/06/2019
'' Purpose :
''---------------------------------------------------------------------------------------
''
'Public Function ExtractSuffix(ByVal strPath As String) As String
' Dim AY() As String ' string array
' Dim Max As Integer
'
' On Error GoTo ExtractSuffix_Error
' If debugflg = 1 Then DebugPrint "%" & "ExtractSuffix"
'
' If strPath = vbNullString Then
' ExtractSuffix = vbNullString
' Exit Function
' End If
'
' If InStr(strPath, ".") <> 0 Then
' AY = Split(strPath, ".")
' Max = UBound(AY)
' ExtractSuffix = AY(Max)
' Else
' ExtractSuffix = strPath
' End If
'
' On Error GoTo 0
' Exit Function
'
'ExtractSuffix_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExtractSuffix of Form dock"
'End Function
''---------------------------------------------------------------------------------------
'' Procedure : Is64bit
'' Author : beededea
'' Date : 04/07/2020
'' Purpose : 'Spider Harper
''---------------------------------------------------------------------------------------
''
'Public Function Is64bit() As Boolean
' Dim Handle As Long
' Dim bolFunc As Boolean
'
' ' Assume initially that this is not a Wow64 process
' On Error GoTo Is64bit_Error
'
' bolFunc = False
'
' ' Now check to see if IsWow64Process function exists
' Handle = GetProcAddress(GetModuleHandle("kernel32"), _
' "IsWow64Process")
'
' If Handle > 0 Then ' IsWow64Process function exists
' ' Now use the function to determine if
' ' we are running under Wow64
' IsWow64Process GetCurrentProcess(), bolFunc
' End If
'
' Is64bit = bolFunc
'
' On Error GoTo 0
' Exit Function
'
'Is64bit_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Is64bit of Module Module1"
'
'End Function
''---------------------------------------------------------------------------------------
'' Procedure : readDockSettingsFile
'' Author : beededea
'' Date : 12/05/2020
'' Purpose : read
''---------------------------------------------------------------------------------------
''
'Private Sub readDockSettingsFile(location As String, settingsFile As String)
'
' 'SteamyDock settings only
' On Error GoTo readDockSettingsFile_Error
' If debugflg = 1 Then DebugPrint "%readDockSettingsFile"
'
' If FExists(dockSettingsFile) Then
' rDGeneralReadConfig = GetINISetting("Software\SteamyDock\DockSettings", "GeneralReadConfig", dockSettingsFile)
' rDGeneralWriteConfig = GetINISetting("Software\SteamyDock\DockSettings", "GeneralWriteConfig", dockSettingsFile)
' rDRunAppInterval = GetINISetting("Software\SteamyDock\DockSettings", "RunAppInterval", dockSettingsFile) ' dean
' rDAlwaysAsk = GetINISetting("Software\SteamyDock\DockSettings", "AlwaysAsk", dockSettingsFile) ' dean
' rDDefaultDock = GetINISetting("Software\SteamyDock\DockSettings", "DefaultDock", dockSettingsFile)
' rDAnimationInterval = GetINISetting("Software\SteamyDock\DockSettings", "AnimationInterval", dockSettingsFile)
' rDSkinSize = GetINISetting("Software\SteamyDock\DockSettings", "SkinSize", dockSettingsFile)
' End If
'
' sDSkinSize = Val(rDSkinSize)
'
' 'if the above settings do not exist in the older RD settings file then no error is thrown so it works for both
'
' 'RocketDock settings only
' rDVersion = GetINISetting(location, "Version", settingsFile) ' dean
' rDHotKeyToggle = GetINISetting(location, "HotKey-Toggle", settingsFile)
' rDtheme = GetINISetting(location, "Theme", settingsFile)
' rDThemeOpacity = GetINISetting(location, "ThemeOpacity", settingsFile)
' rDIconOpacity = GetINISetting(location, "IconOpacity", settingsFile)
' rDFontSize = GetINISetting(location, "FontSize", settingsFile)
' rDFontFlags = GetINISetting(location, "FontFlags", settingsFile)
' rDFontName = GetINISetting(location, "FontName", settingsFile)
' rDFontColor = GetINISetting(location, "FontColor", settingsFile)
' rDFontCharSet = GetINISetting(location, "FontCharSet", settingsFile)
' rDFontOutlineColor = GetINISetting(location, "FontOutlineColor", settingsFile)
' rDFontOutlineOpacity = GetINISetting(location, "FontOutlineOpacity", settingsFile)
' rDFontShadowColor = GetINISetting(location, "FontShadowColor", settingsFile)
' rDFontShadowOpacity = GetINISetting(location, "FontShadowOpacity", settingsFile)
' rDIconMin = GetINISetting(location, "IconMin", settingsFile)
' rdIconMax = GetINISetting(location, "IconMax", settingsFile)
' rDZoomWidth = GetINISetting(location, "ZoomWidth", settingsFile)
' rDZoomTicks = GetINISetting(location, "ZoomTicks", settingsFile)
' rDAutoHide = GetINISetting(location, "AutoHide", settingsFile)
' rDAutoHideTicks = GetINISetting(location, "AutoHideTicks", settingsFile)
' rDAutoHideDelay = GetINISetting(location, "AutoHideDelay", settingsFile)
' rDPopupDelay = GetINISetting(location, "PopupDelay", settingsFile)
' rDIconQuality = GetINISetting(location, "IconQuality", settingsFile)
' rDLangID = GetINISetting(location, "LangID", settingsFile)
' rDHideLabels = GetINISetting(location, "HideLabels", settingsFile)
' rDZoomOpaque = GetINISetting(location, "ZoomOpaque", settingsFile)
' rDLockIcons = GetINISetting(location, "LockIcons", settingsFile)
' rDManageWindows = GetINISetting(location, "ManageWindows", settingsFile)
' rDDisableMinAnimation = GetINISetting(location, "DisableMinAnimation", settingsFile)