Attribute VB_Name = "pdfMod" Global PlaceFile$, ConfigFile$, Steps%, Processing%, cntlTask As Variant, KeyWait%, taskname$, useAPIFocus Global adminUser$, adminPass$, userUser$, userPass$, Program$, ListDocFile$, UserNameFile$, userFullName$ Public Const NoOfData = 2 'Windows desktop virtual folder at the root of the name space Public Const CSIDL_DESKTOP = &H0 'File system directory that contains the 'user's program groups (which are also file 'system directories) Public Const CSIDL_PROGRAMS = &H2 'Control Panel - virtual folder containing 'icons for the control panel applications Public Const CSIDL_CONTROLS = &H3 'Printers folder - virtual folder containing 'installed printers. Public Const CSIDL_PRINTERS = &H4 'File system directory that serves as a 'common repository for documents (Documents folder) Public Const CSIDL_PERSONAL = &H5 'File system directory that contains the 'user's favorite Internet Explorer URLs Public Const CSIDL_FAVORITES = &H6 'File system directory that corresponds to the 'user's Startup program group Public Const CSIDL_STARTUP = &H7 'File system directory that contains the 'user's most recently used documents (Recent folder) Public Const CSIDL_RECENT = &H8 'File system directory that contains 'Send To menu items Public Const CSIDL_SENDTO = &H9 'Recycle bin file system directory containing file 'objects in the user's recycle bin. The location of 'this directory is not in the registry; it is marked 'with the hidden and system attributes to prevent the 'user from moving or deleting it. Public Const CSIDL_BITBUCKET = &HA 'File system directory containing Start menu items Public Const CSIDL_STARTMENU = &HB 'File system directory used to physically store 'file objects on the desktop (not to be confused 'with the desktop folder itself). Public Const CSIDL_DESKTOPDIRECTORY = &H10 'My Computer - virtual folder containing everything 'on the local computer: storage devices, printers, 'and Control Panel. The folder may also contain 'mapped network drives. Public Const CSIDL_DRIVES = &H11 'Network Neighborhood - virtual folder representing 'the top level of the network hierarchy Public Const CSIDL_NETWORK = &H12 'File system directory containing objects that 'appear in the network neighborhood Public Const CSIDL_NETHOOD = &H13 'Virtual folder containing fonts Public Const CSIDL_FONTS = &H14 'File system directory that serves as a 'common repository for document templates '(ShellNew folder.) Public Const CSIDL_TEMPLATES = &H15 'application folder Public Const CSIDL_APPLIC = &H1A ' ' Public Constants Public Const VFT_UNKNOWN = &H0& Public Const VFT_APP = &H1& Public Const VFT_DLL = &H2& Public Const VFT_DRV = &H3& Public Const VFT_FONT = &H4& Public Const VFT_VXD = &H5& Public Const VFT_STATIC_LIB = &H7& Public Type VS_FIXEDFILEINFO dwSignature As Long dwStrucVersion As Long ' e.g. 0x00000042 = "0.42" dwFileVersionMS As Long ' e.g. 0x00030075 = "3.75" dwFileVersionLS As Long ' e.g. 0x00000031 = "0.31" dwProductVersionMS As Long ' e.g. 0x00030010 = "3.10" dwProductVersionLS As Long ' e.g. 0x00000031 = "0.31" dwFileFlagsMask As Long ' = 0x3F for version "0.42" dwFileFlags As Long ' e.g. VFF_DEBUG Or VFF_PRERELEASE dwFileOS As Long ' e.g. VOS_DOS_WINDOWS16 dwFileType As Long ' e.g. VFT_DRIVER dwFileSubtype As Long ' e.g. VFT2_DRV_KEYBOARD dwFileDateMS As Long ' e.g. 0 dwFileDateLS As Long ' e.g. 0 End Type Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type Public Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAborted As Boolean hNameMaps As Long sProgress As String End Type 'Public Const HKEY_CLASSES_ROOT = &H80000000 'Public Const HKEY_CURRENT_USER = &H80000001 'Public Const HKEY_LOCAL_MACHINE = &H80000002 'Public Const HKEY_USERS = &H80000003 'Public Const HKEY_PERFORMANCE_DATA = &H80000004 'Public Const SYNCHRONIZE = &H100000 'Public Const STANDARD_RIGHTS_READ = &H20000 'Public Const STANDARD_RIGHTS_WRITE = &H20000 'Public Const STANDARD_RIGHTS_EXECUTE = &H20000 'Public Const STANDARD_RIGHTS_REQUIRED = &HF0000 'Public Const STANDARD_RIGHTS_ALL = &H1F0000 'Public Const KEY_QUERY_VALUE = &H1 'Public Const KEY_SET_VALUE = &H2 'Public Const KEY_CREATE_SUB_KEY = &H4 'Public Const KEY_ENUMERATE_SUB_KEYS = &H8 'Public Const KEY_NOTIFY = &H10 'Public Const KEY_CREATE_LINK = &H20 'Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE)) 'Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE)) 'Public Const KEY_EXECUTE = (KEY_READ) 'Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE)) 'Public Const ERROR_SUCCESS = 0& '------------------------------------------------- ' ' Public Variables ' ' We changed this to Byte to prevent the string ' mangling of the buffer Public Const FO_MOVE = &H1 Public Const FO_RENAME = &H4 Public Const FOF_SILENT = &H4 Public Const FOF_NOCONFIRMATION = &H10 Public Const FOF_FILESONLY = &H80 Public Const FOF_SIMPLEPROGRESS = &H100 Public Const FOF_NOCONFIRMMKDIR = &H200 Public Const SHARD_PATH = &H2& Public Const VER_PLATFORM_WIN32_NT = 2 Public Const EWX_LOGOFF = 0 Public Const EWX_SHUTDOWN = 1 Public Const EWX_REBOOT = 2 Public Const EWX_FORCE = 4 Public Const CCDEVICENAME = 32 Public Const CCFORMNAME = 32 Public Const DM_BITSPERPEL = &H40000 Public Const DM_PELSWIDTH = &H80000 Public Const DM_PELSHEIGHT = &H100000 Public Const CDS_UPDATEREGISTRY = &H1 Public Const CDS_TEST = &H4 Public Const DISP_CHANGE_SUCCESSFUL = 0 Public Const DISP_CHANGE_RESTART = 1 Public Const ERROR_NOT_ALL_ASSIGNED = 1300 Public Const SE_PRIVILEGE_ENABLED = 2 Public Const TOKEN_QUERY = &H8 Public Const TOKEN_ADJUST_PRIVILEGES = &H20 Type DEVMODE dmDeviceName As String * CCDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type Type LUID lowpart As Long highpart As Long End Type Type LUID_AND_ATTRIBUTES pLuid As LUID Attributes As Long End Type Type TOKEN_PRIVILEGES PrivilegeCount As Long Privileges As LUID_AND_ATTRIBUTES End Type Declare Function GetFocus& Lib "user32" () Declare Function GetForegroundWindow& Lib "user32" () Declare Function SetForegroundWindow& Lib "user32" (ByVal hwnd As Long) Declare Function GetParent& Lib "user32" (ByVal hwnd As Long) Declare Function GetTopWindow& Lib "user32" (ByVal hwnd As Long) Declare Function SetActiveWindow& Lib "user32" (ByVal hwnd As Long) Declare Function SetFocusAPI& Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) Declare Function GetWindowText& Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal jnk As String, ByVal cch As Long) Declare Function FINDWINDOW& Lib "user32" Alias "FindWindowA" (ByVal lpclass As String, ByVal lpwin As String) Declare Function FindWindowEx& Lib "user32" Alias "FindWindowExA" (ByVal lpWinPar As Long, ByVal lpCA As Long, ByVal stclass As String, ByVal stWinNam As String) Declare Function IsWindow& Lib "user32" (ByVal hwnd As Long) Declare Function IsWindowEnabled& Lib "user32" (ByVal hwnd As Long) Declare Function IsWindowVisible& Lib "user32" (ByVal hwnd As Long) Declare Function GetWindow& Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long Declare Function ExitWindowsEx Lib "user32" (ByVal uflags As Long, ByVal dwreserved As Long) As Long Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPriv As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As Any, ByVal lpName As String, lpUid As LUID) As Long Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long Declare Function GetCurrentProcess Lib "kernel32" () As Long Public verbuf() As Byte ' Version buffer Public Filename$ ' Current file to examine Public Declare Function SHAddToRecentDocs Lib "shell32.dll" (ByVal dwFlags As Long, ByVal dwData As String) As Long Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long Public Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long Public Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As Long) As Long Function QuoteAway$(X$) y$ = Mid$(X$, 2): y$ = left$(y$, Len(y$) - 1) QuoteAway$ = y$ End Function Public Function winFindSubWindow&(MainApp&, ChildApp$, RC%) RC% = False: Fw& = 0 ' Call diag("Main " + Str$(MainApp&)) If MainApp& <> 0 Then ca& = 0 Do Nxt& = FindWindowEx(MainApp&, ca&, vbNullString, vbNullString) Buffer$ = WindowName$(Nxt&) ' Call diag("Buffer " + Str$(Nxt&) + " - " + Buffer$) ' Call diag("ChildApp " + ChildApp$) If Buffer$ = ChildApp$ Then Fw& = Nxt& RC% = True Exit Do End If If Nxt& = 0 Then Exit Do End If ca& = Nxt& Loop End If winFindSubWindow& = Fw& End Function Public Function WindowName$(wnd&) If wnd& <> 0 Then Buffer$ = Space(300) winlen& = GetWindowText(wnd&, Buffer$, 250) Buffer$ = left$(Buffer$, winlen&) WindowName$ = Buffer$ End If End Function Public Function FindTheNextWindow&(Nxt&, WindName$) hdx& = 0 hdl& = Nxt& Do hdl& = FindWindowEx&(0&, hdl&, vbNullString, vbNullString) wn$ = WindowName$(hdl&) If hdl& = 0 Then Exit Do If WindName$ = left$(wn$, Len(WindName$)) Then hdx& = hdl& Exit Do End If Loop FindTheNextWindow& = hdx& End Function Public Sub findalllevel(lvl&, WindowString$, List1 As ListBox) ' xxt& = lvl& hdl& = 0 Do hdl& = FindWindowEx&(xxt&, hdl&, vbNullString, vbNullString) If WindowString$ = "" Then List1.AddItem Str(hdl&) Else wn$ = left(WindowName$(hdl&), Len(WindowString$)) If wn$ = WindowString$ Then List1.AddItem Str(hdl&) End If End If If hdl& = 0 Then Exit Do Loop End Sub Public Function searchChildren&(WindowString$, List1 As ListBox) ' ' This routine parses a windowstring formated as follows: ' RootWindowName|ChildName|ChildofChildName... ' requires a listbox (it may be invisible) ' ' returning the window number of the first child meeting the requirements ' returns 0 if none are apply List1.Clear a$ = "0|" + WindowString$ + "~" List1.AddItem a$ ListCountr = 0 Do b$ = List1.List(0) List1.RemoveItem (0) Call PARSE(b$, a$, "~", RC%) Parent$ = b$ Call PARSE(a$, WindowNumber$, "|", RC%) Call PARSE(a$, searchWindow$, "|", RC%) Rest$ = a$ + Parent$ Rt& = Val(WindowNumber$) If searchWindow$ = "" Then ' ' search is done ' List1.Clear List1.AddItem Parent$ searchChildren = Rt& Exit Function End If If searchWindow$ = " " Then searchWindow$ = "" ct& = 0 Do ct& = winFindSubWindow2&(Rt&, ct&, searchWindow$) If ct& <> 0 Then wn$ = WindowName$(ct&) List1.AddItem Trim$(Str$(ct&)) + Rest$ + wn$ + "|" End If Loop Until ct& = 0 Loop Until List1.ListCount = 0 End Function Public Function winFindSubWindow2&(Root&, Nxt&, WindName$) hdx& = 0 hdl& = Nxt& Do hdl& = FindWindowEx&(Root&, hdl&, vbNullString, vbNullString) wn$ = WindowName$(hdl&) If hdl& = 0 Then Exit Do If WindName$ = left$(wn$, Len(WindName$)) Then hdx& = hdl& Exit Do End If Loop winFindSubWindow2& = hdx& End Function Private Function GetSpecialFolder(CSIDL As Long) As String 'a few local variables needed Dim r As Long Dim sPath As String Dim pidl As Long Const NOERROR = 0 Const MAX_LENGTH = 260 'fill pidl with the specified folder item r = SHGetSpecialFolderLocation(Form1.hwnd, CSIDL, pidl) If r = NOERROR Then 'Of the structure is filled, initialize and 'retrieve the path from the id list, and return 'the folder with a trailing slash appended. sPath = Space$(MAX_LENGTH) r = SHGetPathFromIDList(ByVal pidl, ByVal sPath) If r Then GetSpecialFolder = left$(sPath, _ InStr(sPath, Chr$(0)) - 1) & "\" End If End If End Function Private Sub ShellRenameFile(sOldName As String, sNewName As String) 'set some working variables Dim SHFileOp As SHFILEOPSTRUCT Dim r As Long 'add a pair of terminating nulls to each string sOldName = sOldName & Chr$(0) & Chr$(0) sNewName = sNewName & Chr$(0) & Chr$(0) 'set up the options With SHFileOp .wFunc = FO_RENAME .pFrom = sOldName .pTo = sNewName .fFlags = FOF_SILENT Or FOF_NOCONFIRMATION End With 'and rename the file r = SHFileOperation(SHFileOp) End Sub '--end block--'