Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a$=Space(999) : GetModuleFileName_(0,@a$,999) : appname$=GetFilePart(a$)
- WinW=200 : WinH=100
- ;UsePNGImageDecoder()
- Global Image0
- Global AuthorizedModeDone = #False
- Global NewInstall = #False
- Global CurrentPassword$ = Reg_GetValue(#HKEY_CURRENT_USER,"Software\!flash","megasecret","")
- If CurrentPassword$ = ""
- NewInstall = #True
- EndIf
- Image0 = CatchImage(0, ?Image0)
- DataSection
- Image0:
- IncludeBinary "S:\misc\work\!flash\back.bmp"
- EndDataSection
- Procedure AuthorizedMode()
- FreeGadget(2)
- AuthorizedModeDone = #True
- SetGadgetText(1,"Блокирование флешек:")
- SetGadgetText(3,"Ок")
- BlockStatus$ = Reg_GetValue(#HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services\USBSTOR","Start","")
- CheckBoxGadget(4,30,35,14,14,"")
- TextGadget(5,45,35,150,14,"Флешки заблокированы")
- SetGadgetColor(5,#PB_Gadget_BackColor,#White)
- If BlockStatus$ = "4"
- SetGadgetState(4,#PB_Checkbox_Checked)
- Else
- SetGadgetState(4,#PB_Checkbox_Unchecked)
- EndIf
- EndProcedure
- If OpenWindow(0,200,200,WinW-1,WinH-1,"!flash",#PB_Window_Invisible|#PB_Window_ScreenCentered|#PB_Window_BorderLess)
- CenterX = WindowX(0)
- CenterY = WindowY(0)
- SetWindowPos_(WindowID(0), 0, 0, 0, 0, 0, #SWP_HIDEWINDOW)
- SetWindowLong_(WindowID(0),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW)
- SetWindowColor(0,#White)
- ImageGadget(6, 0, 0, 30, 100, Image0)
- Icon = ExtractIcon_(WindowID(0), appname$, 0)
- AddSysTrayIcon(1, WindowID(0), Icon)
- SysTrayIconToolTip(1, "!flash")
- If CreatePopupMenu(0)
- MenuItem(1,"!flash")
- DisableMenuItem(0,1,1)
- MenuBar()
- MenuItem(2, "Выйти")
- EndIf
- Repeat
- Event = WaitWindowEvent()
- If Event = #PB_Event_SysTray And EventType() = #PB_EventType_LeftDoubleClick
- regn.i$ = CreateRoundRectRgn_(0,0,200,100,50,50)
- SetWindowRgn_(WindowID(0), regn.i$, #True)
- SetWindowPos_(WindowID(0), 0, CenterX, CenterY, 0, 0, #SWP_SHOWWINDOW)
- ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_SHOW)
- StickyWindow(0,1)
- If NewInstall = #True
- TextGadget(1,25,10,150,14,"Введите новый пароль:",#PB_Text_Center)
- Else
- TextGadget(1,25,10,150,14,"Введите пароль:",#PB_Text_Center)
- EndIf
- StringGadget(2,60,35,80,14,"",#PB_String_Password|#PB_String_BorderLess)
- If NewInstall = #True
- ;ButtonColorGadget(3,50,60,100,30,"Ок",#Black,#White)
- ButtonGadget(3,50,60,100,30,"Ок")
- Else
- ;ButtonColorGadget(3,50,60,100,30,"Отмена",#Black,#White)
- ButtonGadget(3,50,60,100,30,"Отмена")
- EndIf
- AddKeyboardShortcut(0,#PB_Shortcut_Return,150)
- SetGadgetColor(1,#PB_Gadget_BackColor,#White)
- SetActiveWindow(0)
- SetActiveGadget(2)
- BringWindowToTop_(WindowID(0))
- EndIf
- If EventGadget() = 6
- SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN, #HTCAPTION,0)
- EndIf
- If Event = #PB_Event_SysTray And EventType() = #PB_EventType_RightClick
- DisplayPopupMenu(0, WindowID(0))
- EndIf
- If Event = #PB_Event_Menu And EventMenu() = 2
- Event = #PB_Event_CloseWindow
- EndIf
- If (Event = #PB_Event_Gadget And EventGadget() = 3) Or EventMenu() = 150
- If NewInstall = #True And Len(GetGadgetText(2)) > 1
- NewPassword$ = GetGadgetText(2)
- CurrentPassword$ = MD5Fingerprint(@NewPassword$,StringByteLength(NewPassword$))
- If Reg_KeyExists(#HKEY_CURRENT_USER,"Software\!flash","")
- If Reg_SetValue(#HKEY_CURRENT_USER,"Software\!flash","megasecret",CurrentPassword$,#REG_SZ,"")
- NewInstall = #False
- AuthorizedMode()
- Else
- MessageRequester("Еггог!","Что-то явно пошло не так :(")
- EndIf
- Else
- If Reg_CreateKey(#HKEY_CURRENT_USER,"Software\!flash","") And Reg_SetValue(#HKEY_CURRENT_USER,"Software\!flash","megasecret",CurrentPassword$,#REG_SZ,"")
- NewInstall = #False
- AuthorizedMode()
- Else
- MessageRequester("Еггог!","Что-то явно пошло не так :(")
- EndIf
- EndIf
- Else
- If AuthorizedModeDone = #True
- If GetGadgetState(4) = #PB_Checkbox_Checked
- If Reg_SetValue(#HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services\USBSTOR","Start","4",#REG_DWORD,"")
- FreeGadget(4)
- FreeGadget(5)
- AuthorizedModeDone = #False
- StickyWindow(0,0)
- ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_HIDE)
- Else
- MessageRequester("Еггог!","Что-то явно пошло не так :(")
- EndIf
- Else
- If Reg_SetValue(#HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services\USBSTOR","Start","3",#REG_DWORD,"")
- FreeGadget(4)
- FreeGadget(5)
- AuthorizedModeDone = #False
- StickyWindow(0,0)
- ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_HIDE)
- Else
- MessageRequester("Еггог!","Что-то явно пошло не так :(")
- EndIf
- EndIf
- Else
- StickyWindow(0,0)
- ResizeWindow(0,#PB_Ignore,#PB_Ignore,WinW,WinH) : ShowWindow_(WindowID(0),#SW_HIDE)
- EndIf
- EndIf
- EndIf
- If Event = #PB_Event_Gadget And EventGadget() = 2 And EventType() = #PB_EventType_Change
- If NewInstall = #False
- InputPassword$ = GetGadgetText(2)
- If MD5Fingerprint(@InputPassword$,StringByteLength(InputPassword$)) = CurrentPassword$
- AuthorizedMode()
- EndIf
- EndIf
- EndIf
- Until Event=#PB_Event_CloseWindow
- EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement