python编写脚本方法_python写dnf脚本录制自己点击
雖然退出程序時這些對象的指針都被自動施放了,但是如果你自己又不能確認是否真正地釋放了打開的數據庫對象,那么就有可能數據庫連接沒有馬上被釋放掉,從而被這些對象所占用的內存就再也不能被操作系統再次分配計算機通過地址讀寫地址對應的內存的值,完成變量的賦值和訪問值的功能常用于通過重定向將屬性從一個請求傳遞到另一個請求下面是一個典型的例子,檢測字符串中是否包含一個元音字母:
1、普通的方法:
IfUCase$(char)="A"OrUCase$(char)="E"OrUCase$(char)="I"OrUCase$(char)="O"OrUCase$(char)="U"Then
'itisavowel
EndIf
2、更加簡練的方法:
IfInStr("AaEeIiOoUu",char)Then
'itisavowel
EndIf
同樣,通過單詞中沒有的字符作為分界符,使用InStr來檢查變量的內容
//獲取2008 08 08 是星期幾RebootsaWindows2000PC.ManyexamplesshelltothekernelandjustkillthePC.Thisdoesitproperlyandtakesintoaccountauserprivilages.
'APICallsusedforRebootPC
PrivateConstTOKEN_ADJUST_PRIVILEGES=&H20
PrivateConstTOKEN_QUERY=&H8
PrivateConstSE_PRIVILEGE_ENABLED=&H2
PrivateConstEWX_SHUTDOWNAsLong=1
PrivateConstEWX_FORCEAsLong=4
PrivateConstEWX_REBOOT=2
PrivateTypeLUID
UsedPartAsLong
IgnoredForNowHigh32BitPartAsLong
EndType
PrivateTypeTOKEN_PRIVILEGES
PrivilegeCountAsLong
TheLuidAsLUID
AttributesAsLong
EndType
PrivateDeclareFunctionExitWindowsExLib"user32"(ByValdwOptionsAsLong,ByValdwReservedAsLong)AsLong
PrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLong
PrivateDeclareFunctionOpenProcessTokenLib"advapi32"(ByValProcessHandleAsLong,ByValDesiredAccessAsLong,TokenHandleAsLong)AsLong
PrivateDeclareFunctionLookupPrivilegeValueLib"advapi32"Alias"LookupPrivilegeValueA"(ByVallpSystemNameAsString,ByVallpNameAsString,lpLuidAsLUID)AsLong
PrivateDeclareFunctionAdjustTokenPrivilegesLib"advapi32"(ByValTokenHandleAsLong,ByValDisableAllPrivilegesAsLong,NewStateAsTOKEN_PRIVILEGES,ByValBufferLengthAsLong,PreviousStateAsTOKEN_PRIVILEGES,ReturnLengthAsLong)AsLong
SubRebootPC()
OnLocalErrorGoToRebootPC_ErrorHandler
ConstcsProcName="RebootPC"
DimhProcessHandleAsLong
DimhTokenHandleAsLong
DimtmpLuidAsLUID
DimtkpNewAsTOKEN_PRIVILEGES
DimtkpPreviousAsTOKEN_PRIVILEGES
DimlBufferNeededAsLong
hProcessHandle=GetCurrentProcess()
CallOpenProcessToken(hProcessHandle,TOKEN_ADJUST_PRIVILEGESOrTOKEN_QUERY,hTokenHandle)
'GettheLUIDfortheshutdownprivilege
CallLookupPrivilegeValue("","SeShutdownPrivilege",tmpLuid)
tkpNew.PrivilegeCount=1'Oneprivilegetoset
tkpNew.TheLuid=tmpLuid
tkpNew.Attributes=SE_PRIVILEGE_ENABLED
'Enabletheshutdownprivilegeintheaccesstokenofthisprocess.
lBufferNeeded=0
CallAdjustTokenPrivileges(hTokenHandle,False,tkpNew,Len(tkpPrevious),tkpPrevious,lBufferNeeded)
'ForceaReboot(nooptiontosavefilestocancelout)
CallExitWindowsEx(EWX_FORCEOrEWX_REBOOT,&HFFFF)
ExitSub
RebootPC_ErrorHandler:
CallRaiseError(csModName,csProcName,Err.Number,Err.Description)
EndSub->
Executor executor = (Executor)invocation.getTarget();PrivateDeclareFunctionCreateDirectoryLib"kernel32"Alias"CreateDirectoryA"(ByVallpPathNameAsString,lpSecurityAttributesAsSECURITY_ATTRIBUTES)AsLong
PrivateTypeSECURITY_ATTRIBUTES
nLengthAsLong
lpSecurityDescriptorAsLong
bInheritHandleAsLong
EndType
SubMain()
'在C盤創建了"VB編程樂園"目錄
CallCreateNewDirectory("C:\VB編程樂園")
MsgBox"在C盤創建了VB編程樂園目錄"
EndSub
PublicSubCreateNewDirectory(NewDirectoryAsString)
DimsDirTestAsString
DimSecAttribAsSECURITY_ATTRIBUTES
DimbSuccessAsBoolean
DimsPathAsString
DimiCounterAsInteger
DimsTempDirAsString
DimiFlagAsInteger
iFlag=0
sPath=NewDirectory
IfRight(sPath,Len(sPath))<>""Then
sPath=sPath&""
EndIf
iCounter=1
DoUntilInStr(iCounter,sPath,"")=0
iCounter=InStr(iCounter,sPath,"")
sTempDir=Left(sPath,iCounter)
sDirTest=Dir(sTempDir)
iCounter=iCounter 1
'創建目錄
SecAttrib.lpSecurityDescriptor=&O0
SecAttrib.bInheritHandle=False
SecAttrib.nLength=Len(SecAttrib)
bSuccess=CreateDirectory(sTempDir,SecAttrib)
Loop
EndSub->
總結
以上是生活随笔為你收集整理的python编写脚本方法_python写dnf脚本录制自己点击的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 很好用的全硬盘搜索工具
- 下一篇: Python SPSS教程