easy
modify the registry and set parameters to your program
modify the registry and set parameters to your program
解决方案 »
- 水晶报表如何设置打印内容在打印纸上居中打印
- 在access里如何取得rownumber﹐比如我想刪除當前記錄以下的所有記錄﹐該如何寫呀﹐總不能一條條的的刪吧﹐各位大哥大姐們幫幫忙吧﹗
- 如何在VB程序中实现QQ好友的高级搜索功能(怎样将在程序中填好的搜索数据发送出去,得到显示搜索结果的网页?)
- ACCESS数据库中的表导出为文本文件的问题
- 在网页中如何给ActiveX传递参数?
- 数摸帮忙啊!急!立刻 大家顶啊 在线等待啊
- 如何用VB6.0做Windows 200的服务?
- 请问怎样可以在VB中调用画板(画图)
- 为什么提示我说不能创建对象???
- 有关知识产权问题
- vb高手请留下e_mail小弟有问题请教!!!
- vb书
大笨蛋,你可不笨,出语不凡,但问你的Email.我发信给你。
my Email:[email protected]
To 大家:
谢谢!谢谢大家的支持。我怎样才能让我的EXE文件接受参数?
请email me example or code
CreateAssociation "yprt", App.EXEName, App.Path '先建立文件关联
If Command <> "" Then 'Command 为一个内置的变量,保存着那个程序的启动参数.
播放 command
end if
end sub'================================================================
'以下在.bas中,为建立文件关联之功能。
Option ExplicitPublic Const REG_SZ As Long = 1
Public Const REG_DWORD As Long = 4
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003Public Const ERROR_NONE = 0
Public Const ERROR_BADDB = 1
Public Const ERROR_BADKEY = 2
Public Const ERROR_CANTOPEN = 3
Public Const ERROR_CANTREAD = 4
Public Const ERROR_CANTWRITE = 5
Public Const ERROR_OUTOFMEMORY = 6
Public Const ERROR_INVALID_PARAMETER = 7
Public Const ERROR_ACCESS_DENIED = 8
Public Const ERROR_INVALID_PARAMETERS = 87
Public Const ERROR_NO_MORE_ITEMS = 259Public Const KEY_ALL_ACCESS = &H3F
Public Const REG_OPTION_NON_VOLATILE = 0Public Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As LongPublic Declare Function RegCreateKeyEx _
Lib "advapi32.dll" Alias "RegCreateKeyExA" _
(ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal Reserved As Long, _
ByVal lpClass As String, _
ByVal dwOptions As Long, _
ByVal samDesired As Long, _
ByVal lpSecurityAttributes As Long, _
phkResult As Long, _
lpdwDisposition As Long) As LongPublic Declare Function RegOpenKeyEx _
Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal ulOptions As Long, _
ByVal samDesired As Long, _
phkResult As Long) As LongPublic Declare Function RegSetValueExString _
Lib "advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
ByVal lpValue As String, _
ByVal cbData As Long) As LongPublic Declare Function RegSetValueExLong _
Lib "advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
lpValue As Long, _
ByVal cbData As Long) As Long
Public Sub CreateAssociation(strFileExt As String, strAppName As String, strAppPath As String) Dim sPath As String
'File Associations begin with a listing
'of the default extension under HKEY_CLASSES_ROOT.
'So the first step is to create that
'root extension item
CreateNewKey "." & strFileExt, HKEY_CLASSES_ROOT
'To the extension just added, add a
'subitem where the registry will look for
'commands relating to the .xxx extension
'("MyApp.Document"). Its type is String (REG_SZ)
SetKeyValue "." & strFileExt, "", strAppName & ".Document", REG_SZ
'Create the 'MyApp.Document' item under
'HKEY_CLASSES_ROOT. This is where you'll put
'the command line to execute or other shell
'statements necessary.
CreateNewKey strAppName & ".Document\shell\open\command", HKEY_CLASSES_ROOT
'Set its default item to "MyApp Document".
'This is what is displayed in Explorer against
'for files with a xxx extension. Its type is
'String (REG_SZ)
SetKeyValue strAppName & ".Document", "", strAppName & " Document", REG_SZ
'Finally, add the path to myapp.exe
'Remember to add %1 as the final command
'parameter to assure the app opens the passed
'command line item.
'(results in '"c:\LongPathname\Myapp.exe %1")
'Again, its type is string.
'sPath = "c:\LongPathname\Myapp.exe %1"
sPath = AddPathEnd(strAppPath) & strAppName & ".exe %1" & Chr(0)
SetKeyValue strAppName & ".Document\shell\open\command", "", sPath, REG_SZ
End Sub
Public Function SetValueEx(ByVal hKey As Long, _
sValueName As String, _
lType As Long, _
vValue As Variant) As Long Dim nValue As Long
Dim sValue As String
Select Case lType
Case REG_SZ
sValue = vValue & Chr$(0)
SetValueEx = RegSetValueExString(hKey, _
sValueName, _
0&, _
lType, _
sValue, _
LenB(sValue))
Case REG_DWORD
nValue = vValue
SetValueEx = RegSetValueExLong(hKey, _
sValueName, _
0&, _
lType, _
nValue, _
4)
End Select
End Function
Public Sub CreateNewKey(sNewKeyName As String, _
lPredefinedKey As Long) 'handle to the new key
Dim hKey As Long
'result of the RegCreateKeyEx function
Dim r As Long
r = RegCreateKeyEx(lPredefinedKey, _
sNewKeyName, 0&, _
vbNullString, _
REG_OPTION_NON_VOLATILE, _
KEY_ALL_ACCESS, 0&, hKey, r)
Call RegCloseKey(hKey)End Sub
Public Sub SetKeyValue(sKeyName As String, _
sValueName As String, _
vValueSetting As Variant, _
lValueType As Long) 'result of the SetValueEx function
Dim r As Long
'handle of opened key
Dim hKey As Long
'open the specified key
r = RegOpenKeyEx(HKEY_CLASSES_ROOT, _
sKeyName, 0, _
KEY_ALL_ACCESS, hKey)
r = SetValueEx(hKey, _
sValueName, _
lValueType, _
vValueSetting)
Call RegCloseKey(hKey)End Sub