home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 1999 October / PCpro_1999_10.ISO / Tools / autoww / AUTOSTRT.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-09-30  |  12.4 KB  |  372 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   3  'Fester Dialog
  4.    Caption         =   "AutoRun Manager"
  5.    ClientHeight    =   3615
  6.    ClientLeft      =   2175
  7.    ClientTop       =   3360
  8.    ClientWidth     =   4935
  9.    Icon            =   "autostrt.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'ZReihenfolge
  14.    ScaleHeight     =   3615
  15.    ScaleWidth      =   4935
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'Bildschirmmitte
  18.    Begin VB.CommandButton Command1 
  19.       Caption         =   "&Abbrechen"
  20.       Height          =   375
  21.       Index           =   3
  22.       Left            =   2520
  23.       TabIndex        =   14
  24.       Top             =   3180
  25.       Width           =   1215
  26.    End
  27.    Begin VB.Frame Frame1 
  28.       Caption         =   "Sofortiger Start"
  29.       Height          =   1332
  30.       Index           =   2
  31.       Left            =   60
  32.       TabIndex        =   11
  33.       Top             =   1740
  34.       Width           =   2352
  35.       Begin VB.CheckBox Check1 
  36.          Caption         =   "&Programm-CD"
  37.          Height          =   372
  38.          Index           =   7
  39.          Left            =   900
  40.          TabIndex        =   13
  41.          Top             =   840
  42.          Width           =   1332
  43.       End
  44.       Begin VB.CheckBox Check1 
  45.          Caption         =   "&Musik-CD"
  46.          Height          =   372
  47.          Index           =   0
  48.          Left            =   900
  49.          TabIndex        =   12
  50.          Top             =   420
  51.          Width           =   1092
  52.       End
  53.       Begin VB.Image Image1 
  54.          Height          =   480
  55.          Index           =   7
  56.          Left            =   240
  57.          Picture         =   "autostrt.frx":0442
  58.          Top             =   240
  59.          Width           =   480
  60.       End
  61.       Begin VB.Image Image1 
  62.          Height          =   480
  63.          Index           =   6
  64.          Left            =   240
  65.          Picture         =   "autostrt.frx":2BE4
  66.          Top             =   720
  67.          Width           =   480
  68.       End
  69.    End
  70.    Begin VB.Frame Frame1 
  71.       Caption         =   "Signal f
  72. r Medienwechsel"
  73.       Height          =   1572
  74.       Index           =   1
  75.       Left            =   60
  76.       TabIndex        =   9
  77.       Top             =   60
  78.       Width           =   2352
  79.       Begin VB.CheckBox Check1 
  80.          Caption         =   "&aktiv"
  81.          Height          =   372
  82.          Index           =   1
  83.          Left            =   900
  84.          TabIndex        =   10
  85.          Top             =   1080
  86.          Width           =   1032
  87.       End
  88.       Begin VB.Label Label1 
  89.          BorderStyle     =   1  'Fest Einfach
  90.          Caption         =   "(Kein Ger
  91. t gefunden)"
  92.          Height          =   615
  93.          Left            =   180
  94.          TabIndex        =   15
  95.          Top             =   360
  96.          Width           =   1995
  97.       End
  98.       Begin VB.Image Image1 
  99.          Height          =   480
  100.          Index           =   5
  101.          Left            =   240
  102.          Picture         =   "autostrt.frx":3026
  103.          Top             =   1020
  104.          Width           =   480
  105.       End
  106.    End
  107.    Begin VB.CommandButton Command1 
  108.       Caption         =   "&OK"
  109.       Height          =   372
  110.       Index           =   2
  111.       Left            =   3780
  112.       TabIndex        =   5
  113.       Top             =   3180
  114.       Width           =   1092
  115.    End
  116.    Begin VB.CommandButton Command1 
  117.       Caption         =   "&Standard"
  118.       Height          =   372
  119.       Index           =   1
  120.       Left            =   1260
  121.       TabIndex        =   6
  122.       Top             =   3180
  123.       Width           =   1152
  124.    End
  125.    Begin VB.CommandButton Command1 
  126.       Caption         =   "&Info"
  127.       Height          =   372
  128.       Index           =   0
  129.       Left            =   60
  130.       TabIndex        =   7
  131.       Top             =   3180
  132.       Width           =   1152
  133.    End
  134.    Begin VB.Frame Frame1 
  135.       Caption         =   "AutoRun erlauben"
  136.       Height          =   3012
  137.       Index           =   0
  138.       Left            =   2520
  139.       TabIndex        =   8
  140.       Top             =   60
  141.       Width           =   2352
  142.       Begin VB.CheckBox Check1 
  143.          Caption         =   "&Ram-Disk"
  144.          Height          =   372
  145.          Index           =   6
  146.          Left            =   900
  147.          TabIndex        =   3
  148.          Top             =   1980
  149.          Width           =   1152
  150.       End
  151.       Begin VB.CheckBox Check1 
  152.          Caption         =   "&CD-ROM"
  153.          Height          =   372
  154.          Index           =   5
  155.          Left            =   900
  156.          TabIndex        =   0
  157.          Top             =   360
  158.          Width           =   1392
  159.       End
  160.       Begin VB.CheckBox Check1 
  161.          Caption         =   "&Netzwerk"
  162.          Height          =   372
  163.          Index           =   4
  164.          Left            =   900
  165.          TabIndex        =   4
  166.          Top             =   2520
  167.          Width           =   1392
  168.       End
  169.       Begin VB.CheckBox Check1 
  170.          Caption         =   "&Festplatte"
  171.          Height          =   372
  172.          Index           =   3
  173.          Left            =   900
  174.          TabIndex        =   2
  175.          Top             =   1440
  176.          Width           =   1152
  177.       End
  178.       Begin VB.CheckBox Check1 
  179.          Caption         =   "&Diskette"
  180.          Height          =   372
  181.          Index           =   2
  182.          Left            =   900
  183.          TabIndex        =   1
  184.          Top             =   900
  185.          Width           =   1332
  186.       End
  187.       Begin VB.Image Image1 
  188.          Height          =   480
  189.          Index           =   2
  190.          Left            =   240
  191.          Picture         =   "autostrt.frx":57C8
  192.          Top             =   1320
  193.          Width           =   480
  194.       End
  195.       Begin VB.Image Image1 
  196.          Height          =   480
  197.          Index           =   4
  198.          Left            =   240
  199.          Picture         =   "autostrt.frx":7F6A
  200.          Top             =   2460
  201.          Width           =   480
  202.       End
  203.       Begin VB.Image Image1 
  204.          Height          =   480
  205.          Index           =   3
  206.          Left            =   240
  207.          Picture         =   "autostrt.frx":A70C
  208.          Top             =   1860
  209.          Width           =   480
  210.       End
  211.       Begin VB.Image Image1 
  212.          Height          =   480
  213.          Index           =   1
  214.          Left            =   240
  215.          Picture         =   "autostrt.frx":AB4E
  216.          Top             =   780
  217.          Width           =   480
  218.       End
  219.       Begin VB.Image Image1 
  220.          Height          =   480
  221.          Index           =   0
  222.          Left            =   240
  223.          Picture         =   "autostrt.frx":D2F0
  224.          Top             =   240
  225.          Width           =   480
  226.       End
  227.    End
  228. Attribute VB_Name = "Form1"
  229. Attribute VB_GlobalNameSpace = False
  230. Attribute VB_Creatable = False
  231. Attribute VB_PredeclaredId = True
  232. Attribute VB_Exposed = False
  233. Option Explicit
  234. Const title = "AutoRun Manager"
  235. Const ERROR_NO_MORE_ITEMS = 259&
  236. Const HKEY_CURRENT_USER = &H80000001
  237. Const HKEY_LOCAL_MACHINE = &H80000002
  238. Const HKEY_DYN_DATA = &H80000006
  239. Const KEY_QUERY_VALUE = &H1
  240. Const KEY_ENUMERATE_SUB_KEYS = &H8
  241. Const REG_NONE = 0
  242. Const REG_SZ = 1
  243. Const REG_EXPAND_SZ = 2
  244. Const REG_BINARY = 3
  245. Const REG_DWORD = 4
  246. Const AutoInsertNotificationName = "AutoInsertNotification"
  247. Const ConfKey = "Config Manager\Enum"
  248. Const AutoRunKey = "software\microsoft\windows\currentversion\policies\explorer"
  249. Const AutoRunKeyName = "NoDriveTypeAutoRun"
  250. Const AudioRunKey = "SOFTWARE\Classes\AudioCD\shell"
  251. Const AudioRunActiveValue = "play"
  252. Dim crlf As String
  253. Dim NoDriveTypeAutoRunValue As String * 4
  254. Dim AudioRunValue As String
  255. Dim AutoInsertNotificationValue As String * 1
  256. Dim HardWareKey As String
  257. Private Sub Check1_Click(Index As Integer)
  258.     Select Case Index
  259.         Case 5
  260.             Check1(7).Value = Check1(5).Value
  261.         Case 7
  262.             Check1(5).Value = Check1(7).Value
  263.     End Select
  264. End Sub
  265. Private Sub Command1_Click(Index As Integer)
  266.     Select Case Index
  267.         Case 3 'abbr
  268.             End
  269.         Case 2 'ok
  270.             SaveValues
  271.             End
  272.         Case 1 'standard
  273.             SetDefaultValues
  274.         Case 0 'info
  275.             ww_info title, "Ein Tool zum Bearbeiten der AutoRun-Funktionen von Win95."
  276.     End Select
  277. End Sub
  278. Private Sub Form_Load()
  279. crlf = Chr$(13) + Chr$(10)
  280. ReadValuesFromRegistry
  281. End Sub
  282. Public Sub SetDefaultValues()
  283. Dim i As Integer
  284. For i = 2 To 6
  285.     Select Case i
  286.         Case 2, 4
  287.             Check1(i).Value = 0
  288.         Case Else
  289.             Check1(i).Value = 1
  290.     End Select
  291. Check1(0).Value = 1
  292. End Sub
  293. Public Sub SaveValues()
  294. Dim b As Byte
  295. Dim rc As Long
  296. Dim hKey As Long
  297. Dim i As Integer
  298.     'NoDriveTypeAutoRun
  299.     b = Asc(NoDriveTypeAutoRunValue)
  300.     For i = 2 To 6
  301.         b = b And Not (2 ^ i) Or (2 ^ i) * -(Check1(i).Value = 0) 'bei gel
  302. . eig. muss bit=1 sein und umgek.
  303.     Next
  304.     Mid$(NoDriveTypeAutoRunValue, 1, 1) = Chr$(b)
  305.     rc = RegOpenKeyEx(HKEY_CURRENT_USER, AutoRunKey, 0, KEY_QUERY_VALUE, hKey)
  306.     rc = RegSetValueEx(hKey, AutoRunKeyName, 0, REG_BINARY, ByVal NoDriveTypeAutoRunValue, Len(NoDriveTypeAutoRunValue))
  307.     rc = RegCloseKey(hKey)
  308.     '"AudioRunKey"
  309.     If Check1(0).Value Then
  310.         AudioRunValue = AudioRunActiveValue
  311.     Else
  312.         AudioRunValue = ""
  313.     End If
  314.     rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AudioRunKey, 0, KEY_QUERY_VALUE, hKey)
  315.     rc = RegSetValueEx(hKey, "", 0, REG_SZ, ByVal AudioRunValue, Len(AudioRunValue))
  316.     rc = RegCloseKey(hKey)
  317.     'hw notify
  318.     AutoInsertNotificationValue = Chr$(Check1(1).Value)
  319.     rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Enum\" + HardWareKey, 0, KEY_QUERY_VALUE, hKey)
  320.     rc = RegSetValueEx(hKey, AutoInsertNotificationName, 0, REG_BINARY, ByVal AutoInsertNotificationValue, Len(AutoInsertNotificationValue))
  321.     rc = RegCloseKey(hKey)
  322. End Sub
  323. Public Sub ReadValuesFromRegistry()
  324. Dim i As Integer
  325. Dim rc As Long
  326. Dim hKey As Long
  327. Dim rc1 As Long
  328. Dim DeviceDesc As String
  329. Dim CMEnumKey As String
  330. Dim KeyNum As Long
  331. Dim hKey1 As Long
  332.     '"NoDriveTypeAutoRun" einlesen
  333.     rc = RegOpenKeyEx(HKEY_CURRENT_USER, AutoRunKey, 0, KEY_QUERY_VALUE, hKey)
  334.     rc = RegQueryValueEx(hKey, AutoRunKeyName, 0, REG_BINARY, ByVal NoDriveTypeAutoRunValue, Len(NoDriveTypeAutoRunValue))
  335.     rc = RegCloseKey(hKey)
  336.     For i = 2 To 6   'NoDriveTypeAutoRun bits auf die checkboxen verteilen
  337.         Check1(i).Value = -((Asc(NoDriveTypeAutoRunValue) And (2 ^ i)) = 0)
  338.     Next
  339.     '"AudioRunKey" einlesen
  340.     AudioRunValue = Space$(256)
  341.     rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AudioRunKey, 0, KEY_QUERY_VALUE, hKey)
  342.     rc = RegQueryValueEx(hKey, "", 0, REG_SZ, ByVal AudioRunValue, Len(AudioRunValue))
  343.     rc = RegCloseKey(hKey)
  344.     Check1(0).Value = -(LCase(ztrim(AudioRunValue)) = AudioRunActiveValue)
  345.     'AutoInsertNotification
  346.     rc = RegOpenKeyEx(HKEY_DYN_DATA, ConfKey, 0, KEY_ENUMERATE_SUB_KEYS, hKey)
  347.     Do
  348.         CMEnumKey = Space$(256)
  349.         If RegEnumKey(hKey, KeyNum, CMEnumKey, Len(CMEnumKey)) Then Exit Do
  350.         CMEnumKey = ztrim(CMEnumKey)
  351.         'hw pfad einlesen
  352.         HardWareKey = Space$(256)
  353.         rc = RegOpenKeyEx(HKEY_DYN_DATA, ConfKey + "\" + CMEnumKey, 0, KEY_QUERY_VALUE, hKey1)
  354.         rc = RegQueryValueEx(hKey1, "HardWareKey", 0, REG_SZ, ByVal HardWareKey, Len(HardWareKey))
  355.         rc = RegCloseKey(hKey1)
  356.         'im hw pfad nach notify eintrag suchen
  357.         rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Enum\" + HardWareKey, 0, KEY_QUERY_VALUE, hKey1)
  358.         rc = RegQueryValueEx(hKey1, AutoInsertNotificationName, 0, REG_BINARY, ByVal AutoInsertNotificationValue, Len(AutoInsertNotificationValue))
  359.         If rc = 0 Then
  360.             DeviceDesc = Space$(256)
  361.             rc = RegQueryValueEx(hKey1, "DeviceDesc", 0, REG_SZ, ByVal DeviceDesc, Len(DeviceDesc))
  362.             Label1.Caption = ztrim(DeviceDesc)
  363.             rc = RegCloseKey(hKey1)
  364.             Check1(1).Value = Sgn(Asc(AutoInsertNotificationValue))
  365.             Exit Do
  366.         End If
  367.         rc = RegCloseKey(hKey1)
  368.         KeyNum = KeyNum + 1
  369.     Loop
  370.     rc = RegCloseKey(hKey)
  371. End Sub
  372.