Results 1 to 6 of 6

Thread: Please Read

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Lightbulb

    Okay I know these can be done with API, but havent found the declares in the viewer.
    1. Hiding/showing a disk drive
    2. diabling registry editing(w/o deleting regedit)
    3. Diabling the run dialog
    4. diabling a drives autorun
    Anyone know any of these? Thanks in advance.

    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  2. #2
    Member
    Join Date
    Sep 2000
    Posts
    39

    Talking Policy Settings

    What you are trying to do I guess is set policies for the local system. To accomplish this you need to find the registry keys in
    HKLM\Software\Microsoft\Windows\Current Verssion\Explorer\Policies\
    Use Policy Editor Teplate files (*.pol, *.adm) available with resource kit. Open them in Notepad and find the settings you want to change - this will guide you to the key in Registry.

    Here is an example of hiding a drive letter
    http://support.microsoft.com/support.../Q220/9/55.ASP

    Then simply use REG API calls to change the values of this keys.

    http://www.vb-world.net/registry/registry2/




  3. #3
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Cool

    Turn off Autorun:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
    Services\Cdrom\AutoRun - set value to 0

    (from MSDN)
    HKEY_CURRENT_USER\Software\Microsoft\
    Windows\CurrentVersion\Policies\Explorer


    Under this key, is the following value:

    NoDriveTypeAutoRun = 95 00 00 00


    This value is a single 32-bit number. When Windows is installed, the default value is 0x00000095. Only the low bits, 0 through 7, are used. The remaining bits are reserved and should always be set to 0. Each of the low 7 bits corresponds to a possible return value from the GetDriveType function. This function returns one of the values listed in Figure 3.
    A value of 0x00000095 is the same as 10010101 binary. This means that bits 0, 2, 4, and 7 are turned on. The bits that are turned on represent the drive types for which AutoPlay is disabled. In this example, AutoPlay is disabled for unknown drives, removable drives, remote drives, and some undefined types of drives. One thing to note is that on Windows NT you must log off and log on again for this AutoPlay registry change to take effect. On Windows 95, the change takes effect immediately upon changing the registry value.
    Other than that shtirliz' post is right - policies.
    C/C++,Delphi,VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
    I love deadlines. I like the whooshing sound they make as they fly by.
    —Douglas Adams

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Thanks...

    Thanks, I forgot I psted this is ASP also
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  5. #5
    Guest
    To disable the Run Dialog, you can use a Timer to search for any dialog-classed window with the name of "Run" and close it if it's found.

    Add the following to a Form with a Timer.
    Code:
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Const WM_CLOSE = &H10
    
    Private Sub Form_Load()
        Timer1.Interval = 1
    End Sub
    
    Private Sub Timer1_Timer()
    
        Dim Wnd As Long
        Wnd = FindWindowEx(0, 0, "#32770", "Run")
        
        If Wnd <> 0 Then
            SendMessage Wnd, WM_CLOSE, 0, 0
            DestroyWindow Wnd
        End If
        
    End Sub

  6. #6
    Guest
    For saving and retrieving registry values, use the following.

    Add this to a Module
    Code:
    Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As Long
    Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String) As Long
    Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal HKEY As Long, ByVal lpValueName As String) As Long
    Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    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 REG_SZ = 1
    
    Function RegQueryStringValue(ByVal HKEY As Long, ByVal strValueName As String)
        Dim lResult As Long
        Dim lValueType As Long
        Dim strBuf As String
        Dim lDataBufSize As Long
        
        On Error GoTo 0
        lResult = RegQueryValueEx(HKEY, strValueName, 0&, lValueType, ByVal 0&, lDataBufSize)
        If lResult = ERROR_SUCCESS Then
            If lValueType = REG_SZ Then
                strBuf = String(lDataBufSize, " ")
                lResult = RegQueryValueEx(HKEY, strValueName, 0&, 0&, ByVal strBuf, lDataBufSize)
                If lResult = ERROR_SUCCESS Then
                    RegQueryStringValue = StripTerminator(strBuf)
                End If
            End If
        End If
    End Function
    
    Public Function GetSettingEx(HKEY As Long, sPath As String, sValue As String)
        Dim KeyHand&
        Dim datatype&
        Call RegOpenKey(HKEY, sPath, KeyHand&)
        GetSettingEx = RegQueryStringValue(KeyHand&, sValue)
        Call RegCloseKey(KeyHand&)
    End Function
    
    Function StripTerminator(ByVal strString As String) As String
        Dim intZeroPos As Integer
    
        intZeroPos = InStr(strString, Chr$(0))
        If intZeroPos > 0 Then
            StripTerminator = Left$(strString, intZeroPos - 1)
        Else
            StripTerminator = strString
        End If
    End Function
    
    Public Sub SaveSettingEx(HKEY As Long, sPath As String, sValue As String, sData As String)
        Dim KeyHand As Long
        Call RegCreateKey(HKEY, sPath, KeyHand)
        Call RegSetValueEx(KeyHand&, sValue, 0, REG_SZ, ByVal sData, Len(sData))
        Call RegCloseKey(KeyHand&)
    End Sub
    Usage:
    Code:
    'Save a Value to the Registry
    SaveSettingEx HKEY_CURRENT_USER, "Software\Myapp", "Testing", "Hello"
    
    
    'Get a value from the Registry
    Retval = GetSettingEx(HKEY_CURRENT_USER, "Software\Myapp", "Testing")
    Print Retval

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width