vb自动关机程序
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
Dim hdlProcessHandle As Long
Dim hdlTokenHandle As Long
Dim tmpLuid As LUID
Dim tkp As TOKEN_PRIVILEGES
Dim tkpNewButIgnored As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long
hdlProcessHandle = GetCurrentProcess()
OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or _
TOKEN_QUERY), hdlTokenHandle
LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid
tkp.PrivilegeCount = 1
tkp.Privileges(0).pLuid = tmpLuid
tkp.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
AdjustTokenPrivileges hdlTokenHandle, False, tkp, _
Len(tkpNewButIgnored), tkpNewButIgnored, _
lBufferNeeded
End Sub
Private Sub Form_Load()
Dim fso As New FileSystemObject
Dim ts As TextStream
Dim txt, iniFilePath As String
iniFilePath = App.Path & "\" & "system.ini"
If fso.FileExists(iniFilePath) Then
Set ts = fso.OpenTextFile(App.Path & "\" & "system.ini")
closeTime = ts.ReadLine
ts.Close
Set ts = Nothing
If Len(Trim(closeTime)) = 0 Then
Set ts = fso.CreateT
相关文档:
这里是 利用replace 函数 在vb中实现 消除空行的一个程序
这里的容器是richtext
可以扩充到其他容器 和其他字符 用于编写查找替换功能
'--------------------------------------------------------------------------------------------
' 消除空行 , 利用instr函数, 搜索文本里的vbcrlf(回车 + 换行), 两个回车替换 ......
在C语言中,escape的符号很好用,
比如
"中国一定强"
这个字串可以写成:
"\x4E2D\x56FD\x4E00\x5B9A\x5F3A"
用字元编码编写程序,在其他不同语言的windows运作时,比较不会有问题。
(我尽量不想在程序中写入中文)
但是vb如果全部要用字元编码写的话,就会很麻烦而且一个一个都要手写成:
ChrW(&H4E2D) ......
Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required dat ......
这段时间在移植项目的过程中,起初我想判断一个字符串中是否存在某字符(串),直接的使用方法是用instr(start,string1,string2,VB compare),但经过分析在VB中可以只用一下方法来判断!
1.常用的INStr方法
Function InStr([Start], [String1], [String2], [Compare A ......
学生时代专业是机械,但是参加工作后,机缘巧合从事了与软件相关的工作,就是对大型工程软件软件做一些二次开发,收获过快乐,收获过辛酸,在一次又一次的得与失中,想找一个地方,找一些人可以慢慢与之分享,与之交流,并期得到帮助或提供帮助!也许你是无意见路过,甚或漂过,但你的注目是我前进的动力,有幸驻足也会让我 ......