將以下代碼保存到模塊中:
成都創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司一直秉承“誠信做人,踏實(shí)做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務(wù)為基礎(chǔ),以質(zhì)量求生存,以技術(shù)求發(fā)展,成交一個(gè)客戶多一個(gè)朋友!專注中小微企業(yè)官網(wǎng)定制,成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站,塑造企業(yè)網(wǎng)絡(luò)形象打造互聯(lián)網(wǎng)企業(yè)效應(yīng)。
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileStringByKeyName Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
ByVal lpString As String, _
Public Function GetIniParam(NomFichier As String, NomSection As String, NomVariable As String) As String
Dim ReadString As String * 255
Dim returnv As String
Dim mResultLen As Integer
mResultLen = GetPrivateProfileString(NomSection, NomVariable, "(Unassigned)", ReadString, Len(ReadString) - 1, NomFichier)
If IsNull(ReadString) Or Left$(ReadString, 12) = "(Unassigned)" Then
Dim Tempvalue As Variant
Dim Message As String
Message = "配置文件 " NomFichier " 不存在."
returnv = ""
Else
returnv = Left$(ReadString, InStr(ReadString, Chr$(0)) - 1)
End If
GetIniParam = returnv
End Function
Public Function WriteWinIniParam(NomDuIni As String, sLaSection As String, sNouvelleCle As String, sNouvelleValeur As String)
Dim iSucccess As Integer
iSucccess = WritePrivateProfileStringByKeyName(sLaSection, sNouvelleCle, sNouvelleValeur, NomDuIni)
If iSucccess = 0 Then
WriteWinIniParam = False
Else
WriteWinIniParam = True
End If
End Function
調(diào)用方法:
Call WriteWinIniParam(App.Path "\LiveUpdate.ini", "LiveUpdate", "AppName", txtAppName.Text)
txtFile.Text = GetIniParam(App.Path "\LiveUpdate.ini", "LiveUpdate", "FILES1")
做exe程序獲取本機(jī)IP地址用
System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList
做web程序獲取客戶端的IP地址用
HttpContext.Current.Request.ServerVariables("REMOTE_ADDR"])
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub GetName()
Dim sJM As String
Dim sMC As String
Dim sIP As String
Dim s As String
s = String(128, Chr(0))
GetComputerName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sJM = s'計(jì)算機(jī)名稱
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘當(dāng)前用戶名稱
End Sub
'用這種方法在遠(yuǎn)程獲得再發(fā)回本機(jī)就可以吧
'取計(jì)算機(jī)型號暫時(shí)不會
FindWindowEx
VB聲明
Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As
String, ByVal lpsz2 As String) As Long
說明
在窗口列表中尋找與指定條件相符的第一個(gè)子窗口
返回值
Long,找到的窗口的句柄。如未找到相符窗口,則返回零。會設(shè)置GetLastError
參數(shù)表
參數(shù)
類型及說明
hWnd1
Long,在其中查找子的父窗口。如設(shè)為零,表示使用桌面窗口(通常說的頂級窗口都被認(rèn)為是桌面的子窗口,所以也會對它們進(jìn)行查找)
hWnd2
Long,從這個(gè)窗口后開始查找。這樣便可利用對FindWindowEx的多次調(diào)用找到符合條件的所有子窗口。如設(shè)為零,表示從第一個(gè)子窗口開始搜索
lpsz1
String,欲搜索的類名。零表示忽略
lpsz2
String,欲搜索的類名。零表示忽略