Dim strAppDir As String = Path.GetDirectoryName( _
Assembly.GetExecutingAssembly().GetName().CodeBase)
2010年7月20日 星期二
2010年7月12日 星期一
VB.net 設定熱鍵 HotKey(非完整)
Public Const MOD_ALT As Integer = &H1 'Alt key
'宣告必須 API
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Long) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
'新增HotKey
Public Overridable Function RegKey(ByRef KeyName As String) As Boolean
If RegisterHotKey(Me.Handle, 29, 0, Keys.Enter) = False Then
KeyName = "Enter"
Return False
End If
If RegisterHotKey(Me.Handle, 1, 0, Keys.F1) = False Then '查詢
KeyName = "F1"
Return False
End If
If RegisterHotKey(Me.Handle, 2, 0, Keys.F2) = False Then '新增
KeyName = "F2"
Return False
End If
If RegisterHotKey(Me.Handle, 3, 0, Keys.F3) = False Then '修改
KeyName = "F3"
Return False
End If
If RegisterHotKey(Me.Handle, 4, 0, Keys.F4) = False Then '刪除
KeyName = "F4"
Return False
End If
If RegisterHotKey(Me.Handle, 5, 0, Keys.F5) = False Then '輸入確認
KeyName = "F5"
Return False
End If
If RegisterHotKey(Me.Handle, 6, 0, Keys.F6) = False Then '取消
KeyName = "F6"
Return False
End If
If RegisterHotKey(Me.Handle, 7, 0, Keys.F7) = False Then
KeyName = "F7"
Return False
End If
If RegisterHotKey(Me.Handle, 8, 0, Keys.F8) = False Then '第一筆
KeyName = "F8"
Return False
End If
If RegisterHotKey(Me.Handle, 9, 0, Keys.F9) = False Then '上一筆
KeyName = "F9"
Return False
End If
If RegisterHotKey(Me.Handle, 10, 0, Keys.F10) = False Then '下一筆
KeyName = "F10"
Return False
End If
If RegisterHotKey(Me.Handle, 11, 0, Keys.F11) = False Then '最後一筆
KeyName = "F11"
Return False
End If
'If RegisterHotKey(Me.Handle, 12, 0, Keys.F12) = False Then '
' KeyName = "F12"
' Return False
'End If
If RegisterHotKey(Me.Handle, 13, MOD_ALT, Keys.F1) = False Then 'detail 查詢
KeyName = "ALT+F1"
Return False
End If
If RegisterHotKey(Me.Handle, 14, MOD_ALT, Keys.F2) = False Then 'detail 新增
KeyName = "ALT+F2"
Return False
End If
If RegisterHotKey(Me.Handle, 15, MOD_ALT, Keys.F3) = False Then 'detail 修改
KeyName = "ALT+F3"
Return False
End If
If RegisterHotKey(Me.Handle, 16, MOD_ALT, Keys.F4) = False Then 'detail 刪除
KeyName = "ALT+F4"
Return False
End If
If RegisterHotKey(Me.Handle, 17, MOD_ALT, Keys.D1) = False Then
KeyName = "ALT+D1"
Return False
End If
If RegisterHotKey(Me.Handle, 18, MOD_ALT, Keys.D2) = False Then
KeyName = "ALT+D2"
Return False
End If
If RegisterHotKey(Me.Handle, 19, MOD_ALT, Keys.D3) = False Then
KeyName = "ALT+D3"
Return False
End If
If RegisterHotKey(Me.Handle, 20, MOD_ALT, Keys.D4) = False Then
KeyName = "ALT+D4"
Return False
End If
If RegisterHotKey(Me.Handle, 21, MOD_ALT, Keys.D5) = False Then
KeyName = "ALT+D5"
Return False
End If
If RegisterHotKey(Me.Handle, 22, MOD_ALT, Keys.D6) = False Then
KeyName = "ALT+D6"
Return False
End If
If RegisterHotKey(Me.Handle, 23, MOD_ALT, Keys.D7) = False Then
KeyName = "ALT+D7"
Return False
End If
If RegisterHotKey(Me.Handle, 24, MOD_ALT, Keys.D8) = False Then
KeyName = "ALT+D8"
Return False
End If
If RegisterHotKey(Me.Handle, 25, MOD_ALT, Keys.D9) = False Then
KeyName = "ALT+D9"
Return False
End If
If RegisterHotKey(Me.Handle, 26, MOD_ALT, Keys.D0) = False Then
KeyName = "ALT+D0"
Return False
End If
Return True
End Function
'解除HotKey
Public Sub UnRegKey()
Call UnregisterHotKey(Me.Handle, 1)
Call UnregisterHotKey(Me.Handle, 2)
Call UnregisterHotKey(Me.Handle, 3)
Call UnregisterHotKey(Me.Handle, 4)
Call UnregisterHotKey(Me.Handle, 5)
Call UnregisterHotKey(Me.Handle, 6)
Call UnregisterHotKey(Me.Handle, 7)
Call UnregisterHotKey(Me.Handle, 8)
Call UnregisterHotKey(Me.Handle, 9)
Call UnregisterHotKey(Me.Handle, 10)
Call UnregisterHotKey(Me.Handle, 11)
Call UnregisterHotKey(Me.Handle, 12)
Call UnregisterHotKey(Me.Handle, 13)
Call UnregisterHotKey(Me.Handle, 14)
Call UnregisterHotKey(Me.Handle, 15)
Call UnregisterHotKey(Me.Handle, 16)
Call UnregisterHotKey(Me.Handle, 17)
Call UnregisterHotKey(Me.Handle, 18)
Call UnregisterHotKey(Me.Handle, 19)
Call UnregisterHotKey(Me.Handle, 20)
Call UnregisterHotKey(Me.Handle, 21)
Call UnregisterHotKey(Me.Handle, 22)
Call UnregisterHotKey(Me.Handle, 23)
Call UnregisterHotKey(Me.Handle, 24)
Call UnregisterHotKey(Me.Handle, 25)
Call UnregisterHotKey(Me.Handle, 26)
Call UnregisterHotKey(Me.Handle, 29)
End Sub
'攔截Windows 訊息
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
'相關資料http://msdn.microsoft.com/zh-tw/library/dd229215.aspx
Const WM_HOTKEY As Integer = &H312
Select Case m.Msg
Case (WM_HOTKEY)
Select Case m.WParam.ToInt32()
Case (1)
F1_KEY()
Case (2)
F2_KEY()
Case (3)
F3_KEY()
Case (4)
F4_KEY()
Case (5)
F5_KEY()
Case (6)
F6_KEY()
Case (7)
F7_KEY()
Case (8)
F8_KEY()
Case (9)
F9_KEY()
Case (10)
F10_KEY()
Case (11)
F11_KEY()
Case (12)
F12_KEY()
Case (13)
ALTF1()
Case (14)
ALTF2()
Case (15)
ALTF3()
Case (16)
ALTF4()
Case (17)
ALTD1()
Case (18)
ALTD2()
Case (19)
ALTD3()
Case (20)
ALTD4()
Case (21)
ALTD5()
Case (22)
ALTD6()
Case (23)
ALTD7()
Case (24)
ALTD8()
Case (25)
ALTD9()
Case (26)
ALTD0()
Case (29)
Enter_KEY()
End Select
Case &H6
If m.WParam.ToInt32() = 1 Or m.WParam.ToInt32() = 2 Then
Dim V_str As String
RegKey(V_str)
'Console.WriteLine("啟動hotkey1")
'Console.WriteLine(V_str)
End If
If m.WParam.ToInt32() = 2097152 Or m.WParam.ToInt32() = 0 Then
UnRegKey()
'Console.WriteLine("移除hotkey1")
End If
'Console.WriteLine(m.WParam.ToInt32() & " @" & Date.Now.ToString("HH:mm:ss"))
End Select
MyBase.WndProc(m)
End Sub
'宣告必須 API
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Long) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
'新增HotKey
Public Overridable Function RegKey(ByRef KeyName As String) As Boolean
If RegisterHotKey(Me.Handle, 29, 0, Keys.Enter) = False Then
KeyName = "Enter"
Return False
End If
If RegisterHotKey(Me.Handle, 1, 0, Keys.F1) = False Then '查詢
KeyName = "F1"
Return False
End If
If RegisterHotKey(Me.Handle, 2, 0, Keys.F2) = False Then '新增
KeyName = "F2"
Return False
End If
If RegisterHotKey(Me.Handle, 3, 0, Keys.F3) = False Then '修改
KeyName = "F3"
Return False
End If
If RegisterHotKey(Me.Handle, 4, 0, Keys.F4) = False Then '刪除
KeyName = "F4"
Return False
End If
If RegisterHotKey(Me.Handle, 5, 0, Keys.F5) = False Then '輸入確認
KeyName = "F5"
Return False
End If
If RegisterHotKey(Me.Handle, 6, 0, Keys.F6) = False Then '取消
KeyName = "F6"
Return False
End If
If RegisterHotKey(Me.Handle, 7, 0, Keys.F7) = False Then
KeyName = "F7"
Return False
End If
If RegisterHotKey(Me.Handle, 8, 0, Keys.F8) = False Then '第一筆
KeyName = "F8"
Return False
End If
If RegisterHotKey(Me.Handle, 9, 0, Keys.F9) = False Then '上一筆
KeyName = "F9"
Return False
End If
If RegisterHotKey(Me.Handle, 10, 0, Keys.F10) = False Then '下一筆
KeyName = "F10"
Return False
End If
If RegisterHotKey(Me.Handle, 11, 0, Keys.F11) = False Then '最後一筆
KeyName = "F11"
Return False
End If
'If RegisterHotKey(Me.Handle, 12, 0, Keys.F12) = False Then '
' KeyName = "F12"
' Return False
'End If
If RegisterHotKey(Me.Handle, 13, MOD_ALT, Keys.F1) = False Then 'detail 查詢
KeyName = "ALT+F1"
Return False
End If
If RegisterHotKey(Me.Handle, 14, MOD_ALT, Keys.F2) = False Then 'detail 新增
KeyName = "ALT+F2"
Return False
End If
If RegisterHotKey(Me.Handle, 15, MOD_ALT, Keys.F3) = False Then 'detail 修改
KeyName = "ALT+F3"
Return False
End If
If RegisterHotKey(Me.Handle, 16, MOD_ALT, Keys.F4) = False Then 'detail 刪除
KeyName = "ALT+F4"
Return False
End If
If RegisterHotKey(Me.Handle, 17, MOD_ALT, Keys.D1) = False Then
KeyName = "ALT+D1"
Return False
End If
If RegisterHotKey(Me.Handle, 18, MOD_ALT, Keys.D2) = False Then
KeyName = "ALT+D2"
Return False
End If
If RegisterHotKey(Me.Handle, 19, MOD_ALT, Keys.D3) = False Then
KeyName = "ALT+D3"
Return False
End If
If RegisterHotKey(Me.Handle, 20, MOD_ALT, Keys.D4) = False Then
KeyName = "ALT+D4"
Return False
End If
If RegisterHotKey(Me.Handle, 21, MOD_ALT, Keys.D5) = False Then
KeyName = "ALT+D5"
Return False
End If
If RegisterHotKey(Me.Handle, 22, MOD_ALT, Keys.D6) = False Then
KeyName = "ALT+D6"
Return False
End If
If RegisterHotKey(Me.Handle, 23, MOD_ALT, Keys.D7) = False Then
KeyName = "ALT+D7"
Return False
End If
If RegisterHotKey(Me.Handle, 24, MOD_ALT, Keys.D8) = False Then
KeyName = "ALT+D8"
Return False
End If
If RegisterHotKey(Me.Handle, 25, MOD_ALT, Keys.D9) = False Then
KeyName = "ALT+D9"
Return False
End If
If RegisterHotKey(Me.Handle, 26, MOD_ALT, Keys.D0) = False Then
KeyName = "ALT+D0"
Return False
End If
Return True
End Function
'解除HotKey
Public Sub UnRegKey()
Call UnregisterHotKey(Me.Handle, 1)
Call UnregisterHotKey(Me.Handle, 2)
Call UnregisterHotKey(Me.Handle, 3)
Call UnregisterHotKey(Me.Handle, 4)
Call UnregisterHotKey(Me.Handle, 5)
Call UnregisterHotKey(Me.Handle, 6)
Call UnregisterHotKey(Me.Handle, 7)
Call UnregisterHotKey(Me.Handle, 8)
Call UnregisterHotKey(Me.Handle, 9)
Call UnregisterHotKey(Me.Handle, 10)
Call UnregisterHotKey(Me.Handle, 11)
Call UnregisterHotKey(Me.Handle, 12)
Call UnregisterHotKey(Me.Handle, 13)
Call UnregisterHotKey(Me.Handle, 14)
Call UnregisterHotKey(Me.Handle, 15)
Call UnregisterHotKey(Me.Handle, 16)
Call UnregisterHotKey(Me.Handle, 17)
Call UnregisterHotKey(Me.Handle, 18)
Call UnregisterHotKey(Me.Handle, 19)
Call UnregisterHotKey(Me.Handle, 20)
Call UnregisterHotKey(Me.Handle, 21)
Call UnregisterHotKey(Me.Handle, 22)
Call UnregisterHotKey(Me.Handle, 23)
Call UnregisterHotKey(Me.Handle, 24)
Call UnregisterHotKey(Me.Handle, 25)
Call UnregisterHotKey(Me.Handle, 26)
Call UnregisterHotKey(Me.Handle, 29)
End Sub
'攔截Windows 訊息
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
'相關資料http://msdn.microsoft.com/zh-tw/library/dd229215.aspx
Const WM_HOTKEY As Integer = &H312
Select Case m.Msg
Case (WM_HOTKEY)
Select Case m.WParam.ToInt32()
Case (1)
F1_KEY()
Case (2)
F2_KEY()
Case (3)
F3_KEY()
Case (4)
F4_KEY()
Case (5)
F5_KEY()
Case (6)
F6_KEY()
Case (7)
F7_KEY()
Case (8)
F8_KEY()
Case (9)
F9_KEY()
Case (10)
F10_KEY()
Case (11)
F11_KEY()
Case (12)
F12_KEY()
Case (13)
ALTF1()
Case (14)
ALTF2()
Case (15)
ALTF3()
Case (16)
ALTF4()
Case (17)
ALTD1()
Case (18)
ALTD2()
Case (19)
ALTD3()
Case (20)
ALTD4()
Case (21)
ALTD5()
Case (22)
ALTD6()
Case (23)
ALTD7()
Case (24)
ALTD8()
Case (25)
ALTD9()
Case (26)
ALTD0()
Case (29)
Enter_KEY()
End Select
Case &H6
If m.WParam.ToInt32() = 1 Or m.WParam.ToInt32() = 2 Then
Dim V_str As String
RegKey(V_str)
'Console.WriteLine("啟動hotkey1")
'Console.WriteLine(V_str)
End If
If m.WParam.ToInt32() = 2097152 Or m.WParam.ToInt32() = 0 Then
UnRegKey()
'Console.WriteLine("移除hotkey1")
End If
'Console.WriteLine(m.WParam.ToInt32() & " @" & Date.Now.ToString("HH:mm:ss"))
End Select
MyBase.WndProc(m)
End Sub
2010年2月24日 星期三
2010年1月22日 星期五
更改遠端桌面 PORT
遠端桌面port在tcp中的預設是3389
因為大家的電腦內建都是如此,所以容易被入侵(如果你的電腦有入侵價值的話)
所以來介紹一下改遠端port的方法:
1.開始>執行>regedit>enter
2.找到HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Wds\Repwd\Tds\Tcp 中的PortNumber>右鍵>修改>點選十進位,然後改成自己想要的數字,四位數比較好
3.再找到HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp 中的PortNumber>右鍵>修改>點選十進位,然後改成剛剛設定的四位數
4.控制台>防火牆>例外>新增連接阜>新增剛剛設定的port>確定
5.最後,記得當你要遠端連線的時候,要在自己的ip後面加上":xxxx" 就像之前寫jsp時要加上":8080:一樣。 例如你的ip是140.123.45.78,port設1234 那遠端時就要輸入:140.123.45.78:123 這樣~相信聰明的大家都會了吧~
因為大家的電腦內建都是如此,所以容易被入侵(如果你的電腦有入侵價值的話)
所以來介紹一下改遠端port的方法:
1.開始>執行>regedit>enter
2.找到HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Wds\Repwd\Tds\Tcp 中的PortNumber>右鍵>修改>點選十進位,然後改成自己想要的數字,四位數比較好
3.再找到HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp 中的PortNumber>右鍵>修改>點選十進位,然後改成剛剛設定的四位數
4.控制台>防火牆>例外>新增連接阜>新增剛剛設定的port>確定
5.最後,記得當你要遠端連線的時候,要在自己的ip後面加上":xxxx" 就像之前寫jsp時要加上":8080:一樣。 例如你的ip是140.123.45.78,port設1234 那遠端時就要輸入:140.123.45.78:123 這樣~相信聰明的大家都會了吧~
2010年1月11日 星期一
讓window mobile 播放MP3 用 vb.net
Imports System.Runtime.InteropServices
Public Class Form1
Private Shared Function SndPlaySync(ByVal Path As String, ByVal Flags As UInteger) As IntPtr
End Function
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim ii As Integer
ii = SndPlaySync("\Storage Card\音樂\2008-12-12 梁文音 - 愛的詩篇\01. 最幸褔的事.mp3", 0)
End Sub
End Class
2009年11月26日 星期四
vb.net 、C# 網頁上applet
所以這叫做vb.net applet? OR C# applet?
有圖有真相
此開發環境為 windows XP 、VS 2008
VB版:
1. 建立 Windows Form 使用者控制項:
2.編譯的標籤,勾選..
『註冊OCM....』
3.在程式裡面,需要在一開使的地方做一些調整
是的,需要Import System...................
跟加上Guid、ComVisible
還有主要的 Class要繼承 UserControl
4.在AssemblyInfo.vb裡面
要加上
5.把您的超級程式碼擺進去吧。。。
..................................................
6.高興的按下三角形編譯吧
7.這個時候HTML需要製作了
OK,大功告成...
C#版的話,自行想像。。。基本上很相近
訂閱:
文章 (Atom)