YOUF Posted June 9, 2008 Share Posted June 9, 2008 'Option Explicit Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey 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, ByVal lpData As String, ByVal cbData As Long) As Long Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const REG_DWORD = 4 Dim nBufferKey As Long Dim nVal As Long Private Sub Form_Load() ' Create a REG_DWORD value Dim dword As Long dword = 2 RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Jet\4.0\Engines", nBufferKey sValueName = "SandBox" RegSetValueEx nBufferKey, sValueName, 0, REG_DWORD, dword, Len(dword) 'nVal = 2 'If RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Jet\4.0\Engines", nBufferKey) = ERROR_SUCCESS Then ' RegSetValueEx nBufferKey, "SandBoxMode", 0, REG_DWORD, nVal, Len(nVal) 'End If 'RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Jet\4.0\Engines", nBufferKey 'RegSetValueEx nBufferKey, "SandBoxMode", 0, REG_DWORD, nVal, Len(nVal) 'MsgBox "Sandbox Mode Changed", vbInformation, "Sandbox" 'RegCloseKey nBufferKey Unload Me End Sub Link to comment Share on other sites More sharing options...
James Posted June 9, 2008 Share Posted June 9, 2008 You need, RegRead(), RegWrite() and MsgBox() Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
YOUF Posted June 9, 2008 Author Share Posted June 9, 2008 (edited) advapi32.dll RegEnumKeyEx() LONG RegEnumKeyEx( HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcName, LPDWORD lpReserved, LPWSTR lpClass, LPDWORD lpcbClass, PFILETIME lpftLastWriteTime ); PFILETIME lpftLastWriteTime is I would like to use. information about one subkey each time it is called and it retrieves the class name of the subkey and the time it was last modified. Edited June 9, 2008 by YOUF Link to comment Share on other sites More sharing options...
James Posted June 9, 2008 Share Posted June 9, 2008 (edited) RegEnumKey() & RegEnumVal() Edited June 9, 2008 by Jiim Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
YOUF Posted June 9, 2008 Author Share Posted June 9, 2008 RegEnumKey() & RegEnumVal()but the time it was last modified, Can not be read out~~~I think that the original time of the KEY record, When necessary, check out this KEY the time it was last modified。 Link to comment Share on other sites More sharing options...
James Posted June 9, 2008 Share Posted June 9, 2008 Not sure sorry. I guess another member with more time can help Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
YOUF Posted June 10, 2008 Author Share Posted June 10, 2008 Not sure sorry. I guess another member with more time can help Or Thank you for your answer. I have just learning autoitscipt, many do not understand, please understanding. Link to comment Share on other sites More sharing options...
YOUF Posted June 14, 2008 Author Share Posted June 14, 2008 const $HKEY_LOCAL_MACHINE = 0x80000002;winreg.h dim $hKey=$HKEY_LOCAL_MACHINE $lpName=DllStructGetPtr(DllStructCreate('char')) $lpcName=DllStructGetPtr(DllStructCreate('short')) $lpClass=DllStructGetPtr(DllStructCreate('char')) $lpcClass=DllStructGetPtr(DllStructCreate('short')) $time=DllStructCreate('char') $lpftLastWriteTime=DllStructGetPtr($time) for $dwIndex= 0 to 5 $tt=dllcall('Advapi32.dll','long','RegEnumKeyEx','ptr',$hKey,'int',$dwIndex,'str',$lpName,'dword*',$lpcName,'byte',0,'str',$lpClass,'dword*',$lpcClass,'int',$lpftLastWriteTime) _ArrayDisplay ($tt) msgbox(0,'',_Date_Time_FileTimeToStr ($Time)) next This can use it ? How to ? Link to comment Share on other sites More sharing options...
YOUF Posted June 17, 2008 Author Share Posted June 17, 2008 No one likes this topic? KEY a registry of the last modified testing. Link to comment Share on other sites More sharing options...
rover Posted June 17, 2008 Share Posted June 17, 2008 (edited) @YOUFyou needed the $tagFILETIME struct for the time returndeclared in StructureConstants.au3, included in Date.au3example uses console window of SciTE editor for DllCall return and errorsEdit1: RegCloseKey return in Consolewrite was $aRet[0], should have been $aRet Edit2: removed struct for $lpcNameexpandcollapse popup#include <Date.au3> Opt('MustDeclareVars', 1) Local $lpcName, $tFILETIME, $tFILETIME2, $lpftLastWriteTime Local $tSystem, $aRet, $systime, $localtime, $time, $ret ;winreg.h - see also Gary Frosts 'API constants for AutoIt' in downloads section ;http://www.autoitscript.com/forum/index.php?autocom=downloads&showfile=16 Global Const $HKEY_CLASSES_ROOT = 0x80000000 Global Const $HKEY_CURRENT_USER = 0x80000001 Global Const $HKEY_LOCAL_MACHINE = 0x80000002 Global Const $HKEY_USERS = 0x80000003 Global Const $HKEY_CURRENT_CONFIG = 0x80000005 ;System error codes: http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx Global Const $ERROR_NO_MORE_ITEMS = 0x103 ; 259 Global Const $ERROR_INVALID_HANDLE = 0x6 Local $hKey = $HKEY_LOCAL_MACHINE Local $lpcName = 255 $tFILETIME = DllStructCreate($tagFILETIME) $lpftLastWriteTime = DllStructGetPtr($tFILETIME) ; for lpname the struct is created internally by dll call if str used instead of ptr ; result returned in array ConsoleWrite(@CRLF) For $dwIndex = 0 To 5 $aRet = DllCall('Advapi32.dll', 'long', 'RegEnumKeyEx', _ 'long', $hKey, _ 'dword', $dwIndex, _ 'str', "", _ 'dword*', $lpcName, _ 'dword', "", _ 'ptr', "", _ 'dword', "", _ 'ptr', $lpftLastWriteTime) If Not IsArray($aRet) Or @error Then ConsoleWrite("! DllCall Error: " & @error & @CRLF) ExitLoop EndIf If $aRet[0] <> 0 Then ConsoleWrite("! System error code: " & $aRet[0] & @CRLF) If $aRet[0] = $ERROR_NO_MORE_ITEMS Then ConsoleWrite("! ERROR_NO_MORE_ITEMS: " & $aRet[0] & @CRLF) ; looping through 0 to 5 (6 keys), only 5 keys in LOCAL_MACHINE ; System error codes: http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx ExitLoop EndIf For $i = 0 To UBound($aRet) - 1 ConsoleWrite("+> $aRet[" & $i & "]: " & $aRet[$i] & @CRLF) Next $tFILETIME2 = _Date_Time_FileTimeToLocalFileTime($lpftLastWriteTime) $tSystem = _Date_Time_FileTimeToSystemTime($lpftLastWriteTime) $systime = _Date_Time_SystemTimeToDateTimeStr($tSystem) $localtime = _Date_Time_FileTimeToStr($tFILETIME2) ConsoleWrite("-> LastWriteTime SystemTime: " & $systime & @CRLF) ConsoleWrite("-> LastWriteTime LocalFileTime: " & $localtime & @CRLF) ConsoleWrite(@CRLF) $time &= $aRet[3] & @CRLF & "LastWriteTime SystemTime: " & _ @TAB & $systime & @CRLF & "LastWriteTime LocalFileTime: " & _ @TAB & $localtime & @CRLF & @CRLF Next MsgBox(0, "LastWriteTime", $time) $ret = _WinAPI_RegCloseKey($hKey) If $ret <> 0 Then ConsoleWrite(@CRLF & "! System error code: " & $aRet & @CRLF) If $ret = $ERROR_INVALID_HANDLE Then ConsoleWrite("! $ERROR_INVALID_HANDLE: " & $ret & @CRLF) ;A handle to the open key to be closed. ;The handle must have been opened by the RegCreateKeyEx, ;RegCreateKeyTransacted, RegOpenKeyEx, RegOpenKeyTransacted, ;or RegConnectRegistry function. ;Note: If the key is not one of the predefined registry keys, ;call the RegCloseKey function after you have finished using the handle Func _WinAPI_RegCloseKey($hKey) ;http://msdn.microsoft.com/en-us/library/ms724837(VS.85).aspx Local $aResult $aResult = DllCall("advapi32.dll", "int", "RegCloseKey", "long", $hKey) If IsArray($aResult) Then $aResult = $aResult[0] Return $aResult EndFunc ;==>_WinAPI_RegCloseKey Edited June 17, 2008 by rover I see fascists... Link to comment Share on other sites More sharing options...
YOUF Posted June 19, 2008 Author Share Posted June 19, 2008 very thank @rover ~ thank Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now