vb.net編譯出來的exe只有依賴.net
創(chuàng)新互聯(lián)專業(yè)提供成都主機(jī)托管四川主機(jī)托管成都服務(wù)器托管四川服務(wù)器托管,支持按月付款!我們的承諾:貴族品質(zhì)、平民價格,機(jī)房位于中國電信/網(wǎng)通/移動機(jī)房,成都服務(wù)器托管服務(wù)有保障!
framework才能運(yùn)行
但有一些第三方工具可以用來把exe用到的assembly和dll打包成一個exe文件,不過這樣的結(jié)果就是exe體積非常大
比如.netz工具,它的官方地址:
使用很簡單,比如你的exe文件是a.exe,直接netz
a.exe就可以把a(bǔ)和它用到的.net代碼一起打包成一個exe
'通過timer控件控制窗口從右下角上升顯示
Private?Sub?Timer1_Tick(ByVal?sender?As?Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick
Me.Top?=?My.Computer.Screen.WorkingArea.Height?-?(Me.Height?*?intCnt?*?0.1)
intCnt?+=?1
If?intCnt??10?Then
Timer1.Stop()
intCnt?=?1
End?If
End?Sub
VB.NET控制臺程序:
Module module3
Sub Main()
Dim i As Integer
Dim num As Integer = -35
Dim R As Integer = 8
Dim arr(33) As Integer
Dim len As Integer
arr = TransToR(num, R)
len = arr(0)
Console.Write(num " 轉(zhuǎn)換成 " R " 進(jìn)制后:" vbTab)
If (arr(1) = 1) Then
Console.Write("-")
End If
For i = len + 1 To 2 Step -1
Console.Write(arr(i))
Next
Console.WriteLine()
arr = TransToSourceCode(num)
Console.Write(num " 轉(zhuǎn)換成32位二進(jìn)制源碼后:" vbTab)
Console.Write(arr(1))
For i = 32 To 2 Step -1
Console.Write(arr(i))
Next
Console.WriteLine()
arr = TransToReverseCode(num)
Console.Write(num " 轉(zhuǎn)換成32位二進(jìn)制反碼后:" vbTab)
Console.Write(arr(1))
For i = 32 To 2 Step -1
Console.Write(arr(i))
Next
Console.WriteLine()
arr = TransToCompensatoryCode(num)
Console.Write(num " 轉(zhuǎn)換成32位二進(jìn)制補(bǔ)碼后:" vbTab)
Console.Write(arr(1))
For i = 32 To 2 Step -1
Console.Write(arr(i))
Next
Console.WriteLine()
End Sub
'將十進(jìn)制數(shù)num轉(zhuǎn)換為R(2=R=9)進(jìn)制數(shù),結(jié)果存在arr數(shù)組中
'arr(0)存儲長度, arr(1)存儲符號位:1為負(fù),0為正
Function TransToR(ByVal num As Integer, ByVal R As Integer) As Integer()
Dim arr(33) As Integer
arr(0) = 0 '初始長度
'設(shè)置符號位
If (num 0) Then
arr(1) = 1
Else
arr(1) = 0
End If
num = Math.Abs(num)
While num 0
arr(0) = arr(0) + 1
arr(arr(0) + 1) = num Mod R
num \= R
End While
Return arr
End Function
'將十進(jìn)制數(shù)num轉(zhuǎn)換為二進(jìn)制原碼
Function TransToSourceCode(ByVal num As Integer) As Integer()
Dim arr(33) As Integer
Dim i As Integer
arr = TransToR(num, 2)
'高位補(bǔ)零
For i = arr(0) + 2 To 32
arr(i) = 0
Next
arr(0) = 32
Return arr
End Function
'將十進(jìn)制數(shù)num轉(zhuǎn)換為二進(jìn)制反碼
Function TransToReverseCode(ByVal num As Integer) As Integer()
Dim arr(33) As Integer
Dim i As Integer
arr = TransToSourceCode(num)
If num = 0 Then
Return arr
End If
'除符號位外各位取反
For i = 2 To 33
arr(i) = 1 - arr(i)
Next
Return arr
End Function
'將十進(jìn)制數(shù)num轉(zhuǎn)換為二進(jìn)制補(bǔ)碼
Function TransToCompensatoryCode(ByVal num As Integer) As Integer()
Dim arr(33) As Integer
Dim i As Integer
Dim c As Integer = 0 '進(jìn)位
arr = TransToReverseCode(num)
If num = 0 Then
Return arr
End If
'末尾加1
i = 2
arr(i) += 1
Do While True
arr(i) = c + arr(i)
c = arr(i) \ 2
arr(i) = arr(i) Mod 2
i += 1
If c 1 Then
Exit Do
End If
Loop
Return arr
End Function
End Module
很難達(dá)到你的要求的,VB好像是獲取不到硬盤的物理序列號的,只能獲取到某一個分區(qū)的序列號.不過可以調(diào)用其它的程序?qū)懙墨@取硬盤物理序列號的dll來獲取,CPU的序列號我用的是wmi.VB本來對底層方面就不是很好
引用api獲得硬盤序列號
Private Declare Function MymachineC Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Form_Load()
Dim AA, 硬盤序列號, Maxlen, Sysflag As Long: Dim VolName, FsysName As String
AA = MymachineC("c:\", VolName, 256, 硬盤序列號, Maxlen, Sysflag, FsysName, 256)
msgbox "C硬盤序列號-機(jī)器碼啦-(16制): " Hex(硬盤序列號)
End Sub