ZdrojovΘ k≤dy
Windows 2000 services - P°φklad zobrazφ seznam definovan²ch slu₧eb (service) v systΘmu Windows 2000 pomocφ Active Directory. Abyste mohli vyskouÜet tento p°φklad, musφte p°idat odkaz na Active DS Type Library a mφt samoz°ejm∞ Windows 2000. Dim oSysInfo As New ActiveDs.WinNTSystemInfo Dim oComp As ActiveDs.IADsComputer Dim oSvc As ActiveDs.IADsService Dim sCompName As String sCompName = "WinNT://" & oSysInfo.ComputerName & ",computer" Set oComp = GetObject(sCompName) oComp.Filter = Array("Service") For Each oSvc In oComp Debug.Print oSvc.DisplayName, oSvc.Status Next Set oComp = Nothing JmΘno poΦφtaΦe a domΘny - Pomocφ Active Directory m∙₧ete ve Windows 2000 zjistit jmΘno poΦφtaΦe a domΘny velmi jednoduÜe (pro fungovßnφ p°φkladu musφte p°idat odkaz na Active DS Type Library). Dim oSysInfo As New ActiveDs.WinNTSystemInfo Debug.Print oSysInfo.ComputerName Debug.Print oSysInfo.DomainName Set oSysInfo = Nothing Seznam domΘn - Seznam domΘn zφskßte pomocφ nßsledujφcφho jednoduchΘho k≤du (pro fungovßnφ p°φkladu musφte p°idat odkaz na Active DS Type Library). Dim ns As IADsContainer, dom As IADs Set ns = GetObject("WinNT:") For Each dom In ns Debug.Print dom.Name, dom.ADsPath Next Pr∙hledn² formulß° - Windows 2000 umo₧≥ujφ nastavit okn∙m stupe≥ pr∙hlednosti pomocφ funkce API SetLayeredWindowAttributes. Stupe≥ pr∙hlednosti m∙₧e nab²vat hodnot z intervalu 0-255 (255 je nepr∙hlednΘ okno). Okno, kterΘmu chcete nastavit pr∙hlednost, musφ b²t vytvo°eno pomocφ API CreateWindowEx s parametrem WS_EX_LAYERED nebo tento parametr musφte nastavit pomocφ API SetWindowLong. Private Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = &H80000 Private Const LWA_ALPHA = &H2 Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) _ As Long Private Declare Function SetLayeredWindowAttributes Lib "user32" _ (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, _ ByVal dwFlags As Long) As Long Public Function TranslucentForm(ByVal hw As Long, ByVal TranslucenceLevel As Byte) _ As Boolean SetWindowLong hW, GWL_EXSTYLE, WS_EX_LAYERED SetLayeredWindowAttributes hW, 0, TranslucenceLevel, LWA_ALPHA TranslucentForm = (Err.LastDllError = 0) End Function 'p°φklad pou₧itφ Private Sub Form_Load() TranslucentForm Me, 128 End Sub GetCurrencyFormat - Funkce formßtuje m∞nu podle nastavenφ systΘmu. Pokud nastane chyba, vrßtφ funkce hodnotu 0, jinak poΦet znak∙ vlo₧en²ch do parametru lpCurrencyStr Declare Function GetCurrencyFormat Lib "kernel32" Alias "GetCurrencyFormatA" _ (ByVal Locale As Long, ByVal dwFlags As Long, ByVal lpValue As String, _ lpFormat As Any, ByVal lpCurrencyStr As String, ByVal cchCurrency As Long) As Long Type CURRENCYFMT NumDigits As Long LeadingZero As Long Grouping As Long lpDecimalSep As String lpThousandSep As String NegativeOrder As Long PositiveOrder As Long lpCurrencySymbol As String End Type
Locale
dwFlags
lpValue
lpFormat
NumDigits
LeadingZero
Grouping
lpDecimalSep
lpThousandSep
NegativeOrder
lpCurrencyStr
cchCurrency
Dim udtCurrency As CURRENCYFMT Dim str As String, ret As Long 'systΘmovΘ nastavenφ str = Space(256) ret = GetCurrencyFormat _ (LOCALE_USER_DEFAULT, 0, "98765432.21", ByVal CLng(0), _ str, Len(str)) Debug.Print Left(str, ret) 'vlastnφ nastavenφ With udtCurrency .NumDigits = 4 .LeadingZero = 1 .Grouping = 3 .lpDecimalSep = "." .lpThousandSep = "," .NegativeOrder = 8 .PositiveOrder = 3 .lpCurrencySymbol = "DEM" End With str = Space(256) ret = GetCurrencyFormat _ (LOCALE_USER_DEFAULT, 0, "98765432.21", udtCurrency, _ str, Len(str)) Debug.Print Left(str, ret) 'funkce Visual Basicu Debug.Print FormatCurrency("98765432.21") ClipCursor - Funkce uzamkne kurzor myÜi v obdΘlnφkovΘ oblasti na obrazovce. Pokud u₧ivatel "p°ejede" okraje oblasti nebo nastavφ pozici kurzoru mimo oblast, kurzor se vrßtφ ihned zp∞t. Kurzor je v oblasti uv∞zn∞n i kdy₧ je program ukonΦen. Pokud funkce skonΦφ v po°ßdku, vrßtφ jakoukoliv nenulovou hodnotu, v p°φpad∞ v²skytu chyby vrßtφ 0. Declare Function ClipCursor Lib "user32.dll" (lpRect As RECT) As Long Type RECT left As Long top As Long right As Long bottom As Long End Type
'Zamkne myÜ v oblasti formulß°e pomocφ VB Private Sub ZamkniMysFrm(frm As Form) Dim r As RECT With frm r.left = .left / Screen.TwipsPerPixelX r.right = (.left + .Width) / Screen.TwipsPerPixelX r.top = .top / Screen.TwipsPerPixelY r.bottom = (.top + .Height) / Screen.TwipsPerPixelY End With ClipCursor r End Sub 'Odemkne myÜ pomocφ VB Private Sub OdemkniMys() Dim r As RECT With Screen r.left = 0 r.right = .Width / .TwipsPerPixelX r.top = 0 r.bottom = .Height / .TwipsPerPixelY End With ClipCursor r End Sub 'RychlejÜφ varianta v²Üe uveden²ch funkcφ pomocφ API Private Sub ZamkniMysFrm(frm As Form) Dim r As RECT GetWindowRect frm.hwnd, r ClipCursor r End Sub Private Sub OdemkniMys() Dim r As RECT, hw As Long hw = GetDesktopWindow() GetWindowRect hw, r ClipCursor r End Sub GetClipCursor - Funkce vracφ sou°adnice obdΘlnφku, ve kterΘm se m∙₧e pohybovat myÜ. Pokud nastane chyba, vracφ funkce hodnotu 0, v opaΦnΘm p°φpad∞ jakoukoliv nenulovou hodnotu. Declare Function GetClipCursor Lib "user32.dll" (lprc As RECT) As Long Type RECT left As Long top As Long right As Long bottom As Long End Type
Dim r As RECT GetClipCursor r Debug.Print "Lev² hornφ roh (x,y) " & r.left & "," & r.top Debug.Print "Prav² dolnφ roh (x,y) " & r.right & "," & r.bottom |
|
© 2001
Vogel Publishing,
design by
ET NETERA