估计你声明有问题!
这是C的原版声明:
typedef struct tagTVITEMA {
UINT mask;
HTREEITEM hItem;
UINT state;
UINT stateMask;
LPSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
LPARAM lParam;
} TVITEMA, FAR *LPTVITEMA;
type TVITEMA
mask as long
hItem as long
state as long
stateMask as long
pszText as long '注意这里!!!!
cchTextMax as long
iImage as long
iSelectedImage as long
cChildren as long
lParam as long
end type
解决办法:自己处理字符串。
用wsprintf输出到由GlobalAlloc分配的buffer 里面去。
这是C的原版声明:
typedef struct tagTVITEMA {
UINT mask;
HTREEITEM hItem;
UINT state;
UINT stateMask;
LPSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
LPARAM lParam;
} TVITEMA, FAR *LPTVITEMA;
type TVITEMA
mask as long
hItem as long
state as long
stateMask as long
pszText as long '注意这里!!!!
cchTextMax as long
iImage as long
iSelectedImage as long
cChildren as long
lParam as long
end type
解决办法:自己处理字符串。
用wsprintf输出到由GlobalAlloc分配的buffer 里面去。
http://www.csdn.net/Expert/topicview.asp?id=640108
http://www.csdn.net/Expert/topicview.asp?id=640109
对了,如果TreeView与你的程序不在同一个进程,那么字符串处理会有问题!
也就是说你无法向对方发送字符串!也无法接受。
别指望了
解决办法:进程注入 (用C)
[email protected]你确定它确实是用的Regedit.exe并且自身没访问注册表?
另:难道不可以换个方法吗? Regedit里显示的都是排序过的,那么你只要得到这些值并排序,那么就可以知道那个值的索引编号了。====================================================================
哦
是个好办法
收到。
另:你刷新一下就可以了!你看 regedit 里面菜单的刷新项,呵呵~~~~
难道还要发一次“WM_COMMAND”消息
呵呵,我已经看过了,但刚重装了系统,手边没合适工具。如果你愿意,可以用SoftICE调试一下看看。我用过之后给我的感觉是:
要求非常严格,regedit必须在前台才能工作。
如果不是前台,它回自动切换到前台。而如果使用spy++等工具,
regedit容易失去焦点,所以工作不正常。要调试:挂上spy++,先把regedit最小化后再使用
以下是部分数据(我有点累了~~~~~~)
<00001> 00090504 S .WM_ERASEBKGND hdc:48010B66
<00002> 00090504 R .WM_ERASEBKGND fErased:True
<00003> 00090504 P WM_PAINT hdc:00000000
<00004> 00090504 S ..WM_WINDOWPOSCHANGING lpwp:0006FD1C
<00005> 00090504 R ..WM_WINDOWPOSCHANGING
<00006> 00090504 S ..WM_SETFOCUS hwndLoseFocus:(null)
<00007> 00090504 R ..WM_SETFOCUS
<00008> 00090504 S .WM_KILLFOCUS hwndGetFocus:00090504
<00009> 00090504 S ..WM_PAINT hdc:00000000
<00010> 00090504 R ..WM_PAINT
<00011> 00090504 R .WM_KILLFOCUS
<00012> 00090504 S .WM_SETFOCUS hwndLoseFocus:00090504
<00013> 00090504 R .WM_SETFOCUS
<00014> 00090504 P WM_PAINT hdc:00000000
<00015> 00090504 S WM_PAINT hdc:00000000
<00016> 00090504 R WM_PAINT
<00017> 00090504 S WM_PAINT hdc:00000000
<00018> 00090504 R WM_PAINT
<00019> 00090504 S TVM_GETNEXTITEM flag:TVGN_CARET hitem:00000000
<00020> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00021> 00090504 S TVM_GETITEMRECT fItemRect:True prc:0006FE84
<00022> 00090504 R TVM_GETITEMRECT fSucceeded:True
<00023> 00090504 S TVM_GETNEXTITEM flag:TVGN_CARET hitem:00000000
<00024> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00025> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00026> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00027> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00078CF8
<00028> 00090504 R TVM_GETNEXTITEM hItem:00076DD0
<00029> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00030> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00031> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00076DD0
<00032> 00090504 R TVM_GETNEXTITEM hItem:00000000
<00033> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00078CF8
<00034> 00090504 R TVM_GETNEXTITEM hItem:00076DD0
<00035> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006FC00
<00036> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00157> 00090504 P WM_PAINT hdc:00000000
<00158> 00090504 S WM_PAINT hdc:00000000
<00159> 00090504 R WM_PAINT
<00160> 00090504 S TVM_GETNEXTITEM flag:TVGN_CARET hitem:00000000
<00161> 00090504 R TVM_GETNEXTITEM hItem:00078FB0
<00162> 00090504 S TVM_GETITEMRECT fItemRect:True prc:0006FE84
<00163> 00090504 R TVM_GETITEMRECT fSucceeded:True
<00164> 00090504 S TVM_GETNEXTITEM flag:TVGN_CARET hitem:00000000
<00165> 00090504 R TVM_GETNEXTITEM hItem:00078FB0
<00166> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00167> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00168> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00078FB0
<00169> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00170> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00171> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00172> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00078CF8
<00173> 00090504 R TVM_GETNEXTITEM hItem:00076DD0
<00174> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00175> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00176> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00076DD0
<00177> 00090504 R TVM_GETNEXTITEM hItem:00000000
<00178> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00078FB0
<00179> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00180> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006FC00
<00181> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00182> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00078FB0
<00183> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00184> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006FC00
<00185> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00186> 00090504 S WM_PAINT hdc:00000000
<00187> 00090504 R WM_PAINT
<00188> 00090504 S TVM_GETNEXTITEM flag:TVGN_CARET hitem:00000000
<00189> 00090504 R TVM_GETNEXTITEM hItem:00079008
<00190> 00090504 S TVM_GETITEMRECT fItemRect:True prc:0006FE84
<00191> 00090504 R TVM_GETITEMRECT fSucceeded:True
<00192> 00090504 S TVM_GETNEXTITEM flag:TVGN_CARET hitem:00000000
<00193> 00090504 R TVM_GETNEXTITEM hItem:00079008
<00194> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00195> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00196> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00079008
<00197> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00198> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00199> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00200> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00078CF8
<00201> 00090504 R TVM_GETNEXTITEM hItem:00076DD0
<00202> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006F7F4
<00203> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00204> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00076DD0
<00205> 00090504 R TVM_GETNEXTITEM hItem:00000000
<00206> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00079008
<00207> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00208> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006FC00
<00209> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00210> 00090504 S TVM_GETNEXTITEM flag:TVGN_PARENT hitem:00079008
<00211> 00090504 R TVM_GETNEXTITEM hItem:00078CF8
<00212> 00090504 S message:0x113E [User-defined:WM_USER+3390] wParam:00000000 lParam:0006FC00
<00213> 00090504 R message:0x113E [User-defined:WM_USER+3390] lResult:00000001
<00214> 00090504 S WM_KILLFOCUS hwndGetFocus:(null)
<00215> 00090504 S .WM_PAINT hdc:00000000
<00216> 00090504 R .WM_PAINT
<00217> 00090504 R WM_KILLFOCUS
只是看见许多TVM_GETITEMRECT,不知道他有什么用
TVM_GETITEMW怎么用?
找到了两篇相关的文章:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/htm/cerefTVM_GETITEM.asp?frame=true&hidetoc=truehttp://support.microsoft.com/default.aspx?scid=kb;EN-US;q155895
呵呵,我都看过了。我不是说过吗?用pszText必须保证同一进程或传递一个对于对方来说有效的指针。平常这些办法只对同一进程有效(建议你看看《Windows高级编程指南》)
我自己做的 ShellTree 文件树不是这样使用的,是
TempTVI.pszText = TempStr
TempTVI.pszText = StrPtr(TempStr) 好象有问题。
我自己做的 ShellTree 文件树不是这样使用的,是
TempTVI.pszText = TempStr
====================================================================
看了http://www.csdn.net/Expert/topicview.asp?id=640108对TVITEM的声明没有
upupupup upupupup upupupup upupupupup
upup upup upup up upup
upup upup upupup upup
upup upup upup up
upup upup upup upup
upup upup upup upup
upup upup upup upup
upup upup upup upup
upup upup upup upup
upup upup upup upup
upup upup upup upup
upup upupup upupup upup
upup up upupupup upupupup upup
upupupupup up upup upupupup
upup
upup
upup
upup
upupupupupup
那个程序是怎么做的
有好多TVM_GETITEMW啊!
我想这种办法暂时来说是比较可以的:Chice_wxg(我怕谁?我是谁!我是流氓我最贼。) ( ) 信誉:97 2002-5-4 22:23:35 得分:0
另:难道不可以换个方法吗? Regedit里显示的都是排序过的,那么你只要得到这些值并排序,那么就可以知道那个值的索引编号了。
Top
回复人: zyl910(910:分儿,我来了!) ( ) 信誉:110 2002-5-4 22:27:51 得分:0
已发
Top
回复人: zyl910(910:分儿,我来了!) ( ) 信誉:110 2002-5-4 22:29:22 得分:0
回复人: chice_wxg(我怕谁?我是谁!我是流氓我最贼。) ( ) 信誉:97 2002-05-04 22:23:00 得分:0
另:难道不可以换个方法吗? Regedit里显示的都是排序过的,那么你只要得到这些值并排序,那么就可以知道那个值的索引编号了。====================================================================
哦
是个好办法
Top
回复人: zyl910(910:分儿,我来了!) ( ) 信誉:110 2002-5-4 22:41:17 得分:0
不一定啊
如果用注册表编辑器新建一个主键,它并没有排序
Top
回复人: Chice_wxg(我怕谁?我是谁!我是流氓我最贼。) ( ) 信誉:97 2002-5-5 8:09:58 得分:0
收到。
另:你刷新一下就可以了!你看 regedit 里面菜单的刷新项,呵呵~~~~
Top
还要遍历菜单
发送WM_COMMAND消息
用SendKeys F5就可以了!
你没注意吗?只有regedit前台的时候才能正常定位,否则出错.
(你可以挂上spy++后再试试)
用的是chice_wxg(我怕谁?我是谁!我是流氓我最贼。) 说的方法ZRegTool.vbp
====================================================================
Type=Exe
Form=FrmMain.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\WINDOWS\SYSTEM\StdOle2.Tlb#OLE Automation
Module=BasTV; BasTV.bas
Module=BasReg; BasReg.bas
IconForm="FrmMain"
Startup="FrmMain"
ExeName32="ZRegTool.exe"
Command32=""
Name="ZRegTool"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="91290"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1FrmMain.frm
====================================================================
VERSION 5.00
Begin VB.Form FrmMain
BorderStyle = 1 'Fixed Single
Caption = "zyl910注册表工具"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List1
Height = 600
Left = 990
TabIndex = 2
Top = 240
Width = 2445
End
Begin VB.TextBox Txt1
Height = 285
Left = 0
TabIndex = 1
Text = "HKEY_CURRENT_USER\Control Panel\International"
Top = 1020
Width = 4665
End
Begin VB.CommandButton CmdWork
Caption = "操作"
Height = 465
Left = 1710
TabIndex = 0
Top = 1650
Width = 1095
End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPrivate Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
Private Const SW_SHOWDEFAULT = 10Private Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As BooleanPrivate Declare Function IsIconic Lib "user32" (ByVal hWnd As Long) As LongPrivate Const MeTitle = "zyl910注册表工具"Public Sub SetFGWindow(ByVal hWnd As Long, Optional ByVal Show As Boolean = True)
If Show Then
If IsIconic(hWnd) Then
ShowWindow hWnd, SW_RESTORE
Else
BringWindowToTop hWnd
End If
Else
ShowWindow hWnd, SW_MINIMIZE
End If
End SubPublic Function RegTVExpand(KeyPath As String) As Boolean
Dim ReghWnd As Long
Dim RegTVhWnd As Long
ReghWnd = FindWindow("RegEdit_RegEdit", vbNullString)
If ReghWnd = 0 Then
Shell "RegEdit", vbNormalFocus
ReghWnd = FindWindow("RegEdit_RegEdit", vbNullString)
If ReghWnd = 0 Then
MsgBox "“注册表编辑器”不能启动!", vbCritical Or vbOKOnly, "错误!"
Exit Function
End If
Else
SetFGWindow ReghWnd
End If
SendKeys "{F5}"
RegTVhWnd = FindWindowEx(ReghWnd, 0, "SysTreeView32", vbNullString)
If RegTVhWnd = 0 Then
MsgBox "不能找到“注册表编辑器”的“TreeView”的句柄!", vbCritical Or vbOKOnly, "错误!"
Exit Function
End If
Dim RootKey As RegRootKey
Dim SubKey As String
If RegSplitKey(KeyPath, RootKey, SubKey) = False Then
MsgBox "该主键不存在", vbCritical Or vbOKOnly, "错误!"
Exit Function
End If
Dim hRoot As Long
Dim hHKEY As Long
Dim hChild As Long
Dim CurKeyPath As String
Dim CurKeyName As String
Dim FindPos As Long
Dim KeyNames() As String
Dim I As Long
Dim MaxI As Long
hRoot = TreeView_GetRoot(RegTVhWnd) '取得根节点的句柄
TreeView_Expand RegTVhWnd, hRoot, TVE_EXPAND '展开根节点
'hChild = TreeView_GetChild(RegTVhWnd, hRoot) '取得根节点下第一个节点的句柄
'TreeView_Expand RegTVhWnd, hChild, TVE_EXPAND '展开根节点下第一个节点
'TreeView_SelectItem RegTVhWnd, hChild '选择项目
'展开HKEY_CLASSES_ROOT等几个主键
hHKEY = TreeView_GetChild(RegTVhWnd, hRoot)
For I = RRK_CLASSES_ROOT To RRK_DYN_DATA
If RegCheckKey(I) Then
If RootKey = I Then
TreeView_Expand RegTVhWnd, hHKEY, TVE_EXPAND
Exit For
Else
hHKEY = TreeView_GetNextSibling(RegTVhWnd, hHKEY)
End If
End If
Next I
'展开子键
FindPos = 1
hChild = hHKEY
Do
'Stop
I = InStr(FindPos, SubKey, "\")
CurKeyPath = Left$(SubKey, FindPos - 1)
If I Then
CurKeyName = UCase$(Mid$(SubKey, FindPos, I - FindPos))
FindPos = I + 1
Else
CurKeyName = UCase$(Mid$(SubKey, FindPos))
FindPos = 0
End If
RegGetAllKeySort RootKey, CurKeyPath, KeyNames
MaxI = UBound(KeyNames)
hChild = TreeView_GetChild(RegTVhWnd, hChild)
For I = 0 To MaxI
If UCase$(KeyNames(I)) = CurKeyName Then
TreeView_Expand RegTVhWnd, hChild, TVE_EXPAND
Exit For
Else
hChild = TreeView_GetNextSibling(RegTVhWnd, hChild)
End If
Next I
Loop While FindPos
TreeView_SelectItem RegTVhWnd, hChild
End FunctionPrivate Sub CmdWork_Click()
Me.Caption = MeTitle + " 处理中……"
Screen.MousePointer = vbHourglass
RegTVExpand Txt1.Text
Screen.MousePointer = vbDefault
Me.Caption = MeTitle
End SubPrivate Sub Form_Load()
List1.AddItem "日期/时间"
List1.AddItem "任意文件的打开方式"
List1.ListIndex = 0
End SubPrivate Sub List1_Click()
Select Case List1.ListIndex
Case 0
Txt1.Text = "HKEY_CURRENT_USER\Control Panel\International"
Case 1
Txt1.Text = "HKEY_CLASSES_ROOT\*\shell"
End Select
End Sub
====================================================================
Attribute VB_Name = "BasReg"
Option Explicit
Option Compare Text '这是注册表编辑器的排序方法Private 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 Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegEnumKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal dwIndex As Long, lpName As Any, ByVal cbName As Long) As Long
Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, lpValueName As Any, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As LongPrivate Const REG_NONE = 0
Private Const REG_SZ = 1
Private Const REG_EXPAND_SZ = 2
Private Const REG_BINARY = 3
Private Const REG_DWORD = 4
Private Const REG_DWORD_BIG_ENDIAN = 5
Private Const REG_DWORD_LITTLE_ENDIAN = 4
Private Const REG_LINK = 6
Private Const REG_MULTI_SZ = 7
Private Const REG_RESOURCE_LIST = 8
Private Const REG_FULL_RESOURCE_DESCRIPTOR = 9
Private Const REG_RESOURCE_REQUIREMENTS_LIST = 10Public Enum RegDataType
RDT_None = REG_NONE
RDT_SZ = REG_SZ
RDT_Expand_SZ = REG_EXPAND_SZ
RDT_Binary = REG_BINARY
RDT_DWord = REG_DWORD
RDT_DWord_Big_Endian = REG_DWORD_BIG_ENDIAN
RDT_Multi_SZ = REG_MULTI_SZ
End EnumPrivate Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const HKEY_PERFORMANCE_DATA = &H80000004
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_DYN_DATA = &H80000006
Private Const HKEY_PERF_ROOT = HKEY_LOCAL_MACHINEPublic Enum RegRootKey
RRK_CLASSES_ROOT = HKEY_CLASSES_ROOT
RRK_CURRENT_USER = HKEY_CURRENT_USER
RRK_LOCAL_MACHINE = HKEY_LOCAL_MACHINE
RRK_USERS = HKEY_USERS
RRK_PERFORMANCE_DATA = HKEY_PERFORMANCE_DATA
RRK_CURRENT_CONFIG = HKEY_CURRENT_CONFIG
RRK_DYN_DATA = HKEY_DYN_DATA
End EnumPrivate Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const KEY_LENGTH_MASK = &HFFFF0000Private Const READ_CONTROL = &H20000Private Const SYNCHRONIZE = &H100000
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const STANDARD_RIGHTS_EXECUTE = (READ_CONTROL)
Private Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)Private Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Private Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Private Const KEY_EXECUTE = (KEY_READ)Private Const ERROR_SUCCESS = 0&
Private Const ERROR_MORE_DATA = 234Public RegError As LongPublic Function GetRegRootKeyName(RootKey As RegRootKey) As String
Select Case RootKey
Case RRK_CLASSES_ROOT: GetRegRootKeyName = "HKEY_CLASSES_ROOT"
Case RRK_CURRENT_USER: GetRegRootKeyName = "HKEY_CURRENT_USER"
Case RRK_LOCAL_MACHINE: GetRegRootKeyName = "HKEY_LOCAL_MACHINE"
Case RRK_USERS: GetRegRootKeyName = "HKEY_USERS"
Case RRK_PERFORMANCE_DATA: GetRegRootKeyName = "HKEY_PERFORMANCE_DATA"
Case RRK_CURRENT_CONFIG: GetRegRootKeyName = "HKEY_CURRENT_CONFIG"
Case RRK_DYN_DATA: GetRegRootKeyName = "HKEY_DYN_DATA"
End Select
End FunctionPublic Function RegCheckKey(ByVal RootKey As RegRootKey, _
Optional ByRef SubKey As String = vbNullString) As Boolean
Dim hKey As Long
If SubKey = "" Then SubKey = vbNullString
If Right(SubKey, 1) = "\" Then SubKey = Left$(SubKey, Len(SubKey) - 1)
If RegOpenKeyEx(RootKey, SubKey, 0, KEY_ALL_ACCESS, hKey) = ERROR_SUCCESS Then
RegCloseKey hKey
RegCheckKey = True
Else
RegCheckKey = False
End If
End FunctionPublic Function RegSplitKey(ByRef KeyPath As String, _
ByRef RootKey As RegRootKey, _
ByRef SubKey As String) As Boolean
Dim RootKeyStr As String
Dim I As Long
I = InStr(KeyPath, "\")
RootKeyStr = Left$(KeyPath, I - 1)
SubKey = Mid$(KeyPath, I + 1)
RootKeyStr = UCase$(RootKeyStr)
For I = RRK_CLASSES_ROOT To RRK_DYN_DATA
If RootKeyStr = GetRegRootKeyName(I) Then
RootKey = I
Exit For
End If
Next I
If I > RRK_DYN_DATA Then Exit Function
RegSplitKey = RegCheckKey(RootKey, SubKey)
End Function
Public Function RegEnumKey(ByVal RootKey As RegRootKey, _
ByRef SubKey As String, _
ByVal Index As Long, _
ByRef KeyName As String, _
Optional ByVal MaxStrLen As Long = 260) As Boolean
Dim Rc As Long
Dim hKey As Long
Dim StrData() As Byte
Dim I As Long
If SubKey = "" Then SubKey = vbNullString
If Right(SubKey, 1) = "\" Then SubKey = Left$(SubKey, Len(SubKey) - 1)
If MaxStrLen <= 0 Then MaxStrLen = 260
Rc = RegOpenKeyEx(RootKey, SubKey, 0, KEY_ALL_ACCESS, hKey)
If Rc = ERROR_SUCCESS Then
RegError = 0
ReDim StrData(0 To MaxStrLen)
Rc = RegEnumKeyA(hKey, Index, StrData(0), MaxStrLen)
If Rc = ERROR_SUCCESS Then
For I = 0 To MaxStrLen
If StrData(I) = 0 Then Exit For
Next I
If I = 0 Then
KeyName = vbNullString
Else
KeyName = StrConv(LeftB(StrData, I), vbUnicode)
End If
RegEnumKey = True
Else
RegError = Rc
'RegEnumKey = False
End If
RegCloseKey hKey
Else
RegError = Rc
'RegEnumKey = False
End If
End Function
Public Function RegGetAllKeySort(ByVal RootKey As RegRootKey, _
ByRef SubKey As String, _
ByRef KeyName() As String, _
Optional ByVal MaxStrLen As Long = 260) As Boolean
Dim Rc As Long
Dim hKey As Long
Dim StrData() As Byte
Dim KeyData() As String
Dim I As Long
Dim J As Long
Dim K As Long
Dim TempStr As String
If SubKey = "" Then SubKey = vbNullString
If Right(SubKey, 1) = "\" Then SubKey = Left$(SubKey, Len(SubKey) - 1)
If MaxStrLen <= 0 Then MaxStrLen = 260
Rc = RegOpenKeyEx(RootKey, SubKey, 0, KEY_ALL_ACCESS, hKey)
If Rc = ERROR_SUCCESS Then
RegError = 0
ReDim StrData(0 To MaxStrLen)
I = 0
Do
Rc = RegEnumKeyA(hKey, I, StrData(0), MaxStrLen)
If Rc <> ERROR_SUCCESS Then Exit Do
For J = 0 To MaxStrLen
If StrData(J) = 0 Then Exit For
Next J
ReDim Preserve KeyData(0 To I)
If J = 0 Then
TempStr = vbNullString
Else
TempStr = StrConv(LeftB(StrData, J), vbUnicode)
End If
For J = 0 To I - 1
If TempStr < KeyData(J) Then
For K = I To J + 1 Step -1
KeyData(K) = KeyData(K - 1)
Next K
Exit For
End If
Next J
KeyData(J) = TempStr
I = I + 1
Loop
RegCloseKey hKey
KeyName = KeyData
RegGetAllKeySort = True
Else
RegError = Rc
'RegGetAllKeySort = False
End If
End Function
====================================================================
Attribute VB_Name = "BasTV"
Option ExplicitPublic Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)Public Enum TVMessages
TV_FIRST = &H1100
#If UNICODE Then
TVM_INSERTITEM = (TV_FIRST + 50)
#Else
TVM_INSERTITEM = (TV_FIRST + 0)
#End If
TVM_DELETEITEM = (TV_FIRST + 1)
TVM_EXPAND = (TV_FIRST + 2)
TVM_GETITEMRECT = (TV_FIRST + 4)
TVM_GETCOUNT = (TV_FIRST + 5)
TVM_GETINDENT = (TV_FIRST + 6)
TVM_SETINDENT = (TV_FIRST + 7)
TVM_GETIMAGELIST = (TV_FIRST + 8)
TVM_SETIMAGELIST = (TV_FIRST + 9)
TVM_GETNEXTITEM = (TV_FIRST + 10)
TVM_SELECTITEM = (TV_FIRST + 11)
#If UNICODE Then
TVM_GETITEM = (TV_FIRST + 62)
TVM_SETITEM = (TV_FIRST + 63)
TVM_EDITLABEL = (TV_FIRST + 65)
#Else
TVM_GETITEM = (TV_FIRST + 12)
TVM_SETITEM = (TV_FIRST + 13)
TVM_EDITLABEL = (TV_FIRST + 14)
#End If
TVM_GETEDITCONTROL = (TV_FIRST + 15)
TVM_GETVISIBLECOUNT = (TV_FIRST + 16)
TVM_HITTEST = (TV_FIRST + 17)
TVM_CREATEDRAGIMAGE = (TV_FIRST + 18)
TVM_SORTCHILDREN = (TV_FIRST + 19)
TVM_ENSUREVISIBLE = (TV_FIRST + 20)
TVM_SORTCHILDRENCB = (TV_FIRST + 21)
TVM_ENDEDITLABELNOW = (TV_FIRST + 22)
#If UNICODE Then
TVM_GETISEARCHSTRING = (TV_FIRST + 64)
#Else
TVM_GETISEARCHSTRING = (TV_FIRST + 23)
#End If
TVM_SETTOOLTIPS = (TV_FIRST + 24)
TVM_GETTOOLTIPS = (TV_FIRST + 25)
End Enum ' TVMessages
Public Enum TVM_EXPAND_wParam
TVE_COLLAPSE = &H1
TVE_EXPAND = &H2
TVE_TOGGLE = &H3
TVE_EXPANDPARTIAL = &H4000
TVE_COLLAPSERESET = &H8000
End Enum
Public Enum TVM_GETNEXTITEM_wParam
TVGN_ROOT = &H0
TVGN_NEXT = &H1
TVGN_PREVIOUS = &H2
TVGN_PARENT = &H3
TVGN_CHILD = &H4
TVGN_FIRSTVISIBLE = &H5
TVGN_NEXTVISIBLE = &H6
TVGN_PREVIOUSVISIBLE = &H7
TVGN_DROPHILITE = &H8
TVGN_CARET = &H9
End Enum
Public Function TreeView_Expand(hWnd As Long, hitem As Long, flag As Long) As Boolean
TreeView_Expand = SendMessage(hWnd, TVM_EXPAND, ByVal flag, ByVal hitem)
End Function' ======= Begin TreeView_GetNextItem ===========================================' Retrieves the tree-view item that bears the specified relationship to a specified item.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetNextItem(hWnd As Long, hitem As Long, flag As Long) As Long
TreeView_GetNextItem = SendMessage(hWnd, TVM_GETNEXTITEM, ByVal flag, ByVal hitem)
End Function' Retrieves the first child item. The hitem parameter must be NULL.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetChild(hWnd As Long, hitem As Long) As Long
TreeView_GetChild = TreeView_GetNextItem(hWnd, hitem, TVGN_CHILD)
End Function' Retrieves the next sibling item.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetNextSibling(hWnd As Long, hitem As Long) As Long
TreeView_GetNextSibling = TreeView_GetNextItem(hWnd, hitem, TVGN_NEXT)
End Function' Retrieves the previous sibling item.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetPrevSibling(hWnd As Long, hitem As Long) As Long
TreeView_GetPrevSibling = TreeView_GetNextItem(hWnd, hitem, TVGN_PREVIOUS)
End Function' Retrieves the parent of the specified item.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetParent(hWnd As Long, hitem As Long) As Long
TreeView_GetParent = TreeView_GetNextItem(hWnd, hitem, TVGN_PARENT)
End Function' Retrieves the first visible item.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetFirstVisible(hWnd As Long) As Long
TreeView_GetFirstVisible = TreeView_GetNextItem(hWnd, 0, TVGN_FIRSTVISIBLE)
End Function' Retrieves the next visible item that follows the specified item. The specified item must be visible.
' Use the TVM_GETITEMRECT message to determine whether an item is visible.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetNextVisible(hWnd As Long, hitem As Long) As Long
TreeView_GetNextVisible = TreeView_GetNextItem(hWnd, hitem, TVGN_NEXTVISIBLE)
End Function' Retrieves the first visible item that precedes the specified item. The specified item must be visible.
' Use the TVM_GETITEMRECT message to determine whether an item is visible.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetPrevVisible(hWnd As Long, hitem As Long) As Long
TreeView_GetPrevVisible = TreeView_GetNextItem(hWnd, hitem, TVGN_PREVIOUSVISIBLE)
End Function' Retrieves the currently selected item.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetSelection(hWnd As Long) As Long
TreeView_GetSelection = TreeView_GetNextItem(hWnd, 0, TVGN_CARET)
End Function' Retrieves the item that is the target of a drag-and-drop operation.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetDropHilight(hWnd As Long) As Long
TreeView_GetDropHilight = TreeView_GetNextItem(hWnd, 0, TVGN_DROPHILITE)
End Function' Retrieves the topmost or very first item of the tree-view control.
' Returns the handle to the item if successful or 0 otherwise.Public Function TreeView_GetRoot(hWnd As Long) As Long
TreeView_GetRoot = TreeView_GetNextItem(hWnd, 0, TVGN_ROOT)
End Function
'
' ======= End TreeView_GetNextItem =============================================
'' ======= Begin TreeView_Select ================================================' Selects the specified tree-view item, scrolls the item into view, or redraws the item
' in the style used to indicate the target of a drag-and-drop operation.
' Returns TRUE if successful or FALSE otherwise.Public Function TreeView_Select(hWnd As Long, hitem As Long, code As Long) As Boolean
TreeView_Select = SendMessage(hWnd, TVM_SELECTITEM, ByVal code, ByVal hitem)
End Function' Sets the selection to the given item.
' Returns zero if successful or - 1 otherwise.Public Function TreeView_SelectItem(hWnd As Long, hitem As Long) As Boolean
TreeView_SelectItem = TreeView_Select(hWnd, hitem, TVGN_CARET)
End Function
打开HKEY_CLASSES_ROOT里的项目需要50多秒同时我发现
是慢在字符串比较上
如果不加“Option Compare Text”的话
只需要7、8秒但是注册表使用这种方式排序的
我原来想用TRW2000追踪那个程序发什么消息了~对消息下断点也没用~总在VB运行库里转~烦死了~
其实TRW调VB的时候确实很头疼,到处都是__vba???,头都大了 ^_^不过据说如果陪SmartCheck可能好点,具体我也不知道,没用过。
http://www.csdn.net/Expert/topicview.asp?id=640108我为什么要看他的声明,我使用的全部来自 *.h 的头文件,也是这样子使用,也没有出错.这么多高手,我也要试一下,是获取 RegEdit.exe 里面 TreeView 的节点内容.
====================================================================
我试过了
向自己窗体中的TreeView发消息没有问题
但向注册表的TreeView发消息,非法操作#&%$*&$真的有chice_wxg(我怕谁?我是谁!我是流氓我最贼。)说的“如果TreeView与你的程序不在同一个进程,那么字符串处理会有问题!”的问题
很好的书!(当然是C语言的)
是呀,你可以看看MS牛人Richard Jeff 的《Windows高级编程指南》
很好的书!(当然是C语言的)====================================================================
哪里有下载?
中文还是英文的?
有“汉化版”的吗?
反正我知道有卖的,900多页,当枕头正好,我就卖了 :) 大约99RMB(当然是中文的)
也有下载的,我还DOWN过,不过很不好找,URL也被忘了 :(要是看见我再告诉你,OK?
现在打开HKEY_CLASSES_ROOT里的项目只需要1秒多先在BasReg.bas中添加一个函数:
Public Function Reg_Get_RegEdit_TreeView_Item_Pos(ByVal RootKey As RegRootKey, _
ByRef SubKey As String, _
ByRef ItemName As String, _
Optional ByVal MaxStrLen As Long = 260) As Long
Dim Rc As Long
Dim hKey As Long
Dim StrData() As Byte
Dim KeyData() As String
Dim SortPoint() As Long
Dim Count As Long
Dim Index As Long
Dim I As Long
Dim J As Long
Dim K As Long
Dim TempStr As String
Dim FindItemName As String
If SubKey = "" Then SubKey = vbNullString
If Right(SubKey, 1) = "\" Then SubKey = Left$(SubKey, Len(SubKey) - 1)
If MaxStrLen <= 0 Then MaxStrLen = 260
FindItemName = UCase$(ItemName)
Rc = RegOpenKeyEx(RootKey, SubKey, 0, KEY_ALL_ACCESS, hKey)
If Rc = ERROR_SUCCESS Then
RegError = 0
ReDim StrData(0 To MaxStrLen)
I = 0
Count = 0
Do
Rc = RegEnumKeyA(hKey, I, StrData(0), MaxStrLen)
If Rc <> ERROR_SUCCESS Then Exit Do
For J = 0 To MaxStrLen
If StrData(J) = 0 Then Exit For
Next J
If J = 0 Then
TempStr = vbNullString
Else
TempStr = UCase$(StrConv(LeftB(StrData, J), vbUnicode))
End If
If TempStr < FindItemName Then
ReDim Preserve KeyData(0 To Count)
ReDim Preserve SortPoint(0 To Count)
KeyData(Count) = TempStr
SortPoint(Count) = Count
If Count = 0 Then
'
Else
Index = 0
For J = 0 To Count - 1
K = Index
Index = SortPoint(Index)
If TempStr < KeyData(Index) Then
SortPoint(K) = J
SortPoint(Count) = Index
Exit For
End If
Next J
End If
Count = Count + 1
End If
I = I + 1
Loop
RegCloseKey hKey
'KeyName = KeyData
'RegGetAllKeySort = True
Reg_Get_RegEdit_TreeView_Item_Pos = Count
Else
RegError = Rc
Reg_Get_RegEdit_TreeView_Item_Pos = -1
End If
End Function把FrmMain.frm的RegTVExpand改为:
====================================================================
Public Function RegTVExpand(KeyPath As String) As Boolean
Dim ReghWnd As Long
Dim RegTVhWnd As Long
ReghWnd = FindWindow("RegEdit_RegEdit", vbNullString)
If ReghWnd = 0 Then
Shell "RegEdit", vbNormalFocus
ReghWnd = FindWindow("RegEdit_RegEdit", vbNullString)
If ReghWnd = 0 Then
MsgBox "“注册表编辑器”不能启动!", vbCritical Or vbOKOnly, "错误!"
Exit Function
End If
Else
SetFGWindow ReghWnd
End If
SendKeys "{F5}"
RegTVhWnd = FindWindowEx(ReghWnd, 0, "SysTreeView32", vbNullString)
If RegTVhWnd = 0 Then
MsgBox "不能找到“注册表编辑器”的“TreeView”的句柄!", vbCritical Or vbOKOnly, "错误!"
Exit Function
End If
Dim RootKey As RegRootKey
Dim SubKey As String
If RegSplitKey(KeyPath, RootKey, SubKey) = False Then
MsgBox "该主键不存在", vbCritical Or vbOKOnly, "错误!"
Exit Function
End If
Dim hRoot As Long
Dim hHKEY As Long
Dim hChild As Long
Dim CurKeyPath As String
Dim CurKeyName As String
Dim FindPos As Long
Dim Index As Long
'Dim KeyNames() As String
Dim I As Long
'Dim MaxI As Long
hRoot = TreeView_GetRoot(RegTVhWnd) '取得根节点的句柄
TreeView_Expand RegTVhWnd, hRoot, TVE_EXPAND '展开根节点
'hChild = TreeView_GetChild(RegTVhWnd, hRoot) '取得根节点下第一个节点的句柄
'TreeView_Expand RegTVhWnd, hChild, TVE_EXPAND '展开根节点下第一个节点
'TreeView_SelectItem RegTVhWnd, hChild '选择项目
'展开HKEY_CLASSES_ROOT等几个主键
hHKEY = TreeView_GetChild(RegTVhWnd, hRoot)
For I = RRK_CLASSES_ROOT To RRK_DYN_DATA
If RegCheckKey(I) Then
If RootKey = I Then
TreeView_Expand RegTVhWnd, hHKEY, TVE_EXPAND
Exit For
Else
hHKEY = TreeView_GetNextSibling(RegTVhWnd, hHKEY)
End If
End If
Next I
'展开子键
FindPos = 1
hChild = hHKEY
Do
'Stop
I = InStr(FindPos, SubKey, "\")
CurKeyPath = Left$(SubKey, FindPos - 1)
If I Then
CurKeyName = UCase$(Mid$(SubKey, FindPos, I - FindPos))
FindPos = I + 1
Else
CurKeyName = UCase$(Mid$(SubKey, FindPos))
FindPos = 0
End If
hChild = TreeView_GetChild(RegTVhWnd, hChild)
Index = Reg_Get_RegEdit_TreeView_Item_Pos(RootKey, CurKeyPath, CurKeyName)
If Index < 0 Then
MsgBox "Error", vbCritical Or vbOKOnly
Exit Do
End If
For I = 1 To Index
hChild = TreeView_GetNextSibling(RegTVhWnd, hChild)
Next I
TreeView_Expand RegTVhWnd, hChild, TVE_EXPAND
Loop While FindPos
TreeView_SelectItem RegTVhWnd, hChild
End Function
原作者的程序不需要VB运行库~为什么?什么情况不需要运行库?
====================================================================
因为Win97(及以上版本)自带了VB5运行库,而它是用VB5编的
现在普遍用Win98 SE了,WinXP都有
只需要运行库即可运行
实际上只需要判断在所需要展开的项目前面有多少过项目就行了把BasReg.bas里的Reg_Get_RegEdit_TreeView_Item_Pos该为:
Public Function Reg_Get_RegEdit_TreeView_Item_Pos(ByVal RootKey As RegRootKey, _
ByRef SubKey As String, _
ByRef ItemName As String, _
Optional ByVal MaxStrLen As Long = 260) As Long
Dim Rc As Long
Dim hKey As Long
Dim StrData() As Byte
Dim Count As Long
Dim I As Long
Dim J As Long
Dim TempStr As String
If SubKey = "" Then SubKey = vbNullString
If Right(SubKey, 1) = "\" Then SubKey = Left$(SubKey, Len(SubKey) - 1)
If MaxStrLen <= 0 Then MaxStrLen = 260
Rc = RegOpenKeyEx(RootKey, SubKey, 0, KEY_ALL_ACCESS, hKey)
If Rc = ERROR_SUCCESS Then
RegError = 0
ReDim StrData(0 To MaxStrLen)
I = 0
Count = 0
Do
Rc = RegEnumKeyA(hKey, I, StrData(0), MaxStrLen)
If Rc <> ERROR_SUCCESS Then Exit Do
For J = 0 To MaxStrLen
If StrData(J) = 0 Then Exit For
Next J
If J = 0 Then
TempStr = vbNullString
Else
TempStr = StrConv(LeftB(StrData, J), vbUnicode)
End If
If TempStr < ItemName Then
Count = Count + 1
End If
I = I + 1
Loop
RegCloseKey hKey
'KeyName = KeyData
'RegGetAllKeySort = True
Reg_Get_RegEdit_TreeView_Item_Pos = Count
Else
RegError = Rc
Reg_Get_RegEdit_TreeView_Item_Pos = -1
End If
End Function
你的代码的前端的声明怎么弄出来的?从这里开始~------------------------------------------ZRegTool.vbp
====================================================================
Type=Exe
Form=FrmMain.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\WINDOWS\SYSTEM\StdOle2.Tlb#OLE Automation
Module=BasTV; BasTV.bas
Module=BasReg; BasReg.bas
IconForm="FrmMain"
Startup="FrmMain"
ExeName32="ZRegTool.exe"
Command32=""
Name="ZRegTool"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="91290"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1FrmMain.frm
====================================================================
VERSION 5.00
Begin VB.Form FrmMain
BorderStyle = 1 'Fixed Single
Caption = "zyl910注册表工具"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List1
Height = 600
Left = 990
TabIndex = 2
Top = 240
Width = 2445
End
Begin VB.TextBox Txt1
Height = 285
Left = 0
TabIndex = 1
Text = "HKEY_CURRENT_USER\Control Panel\International"
Top = 1020
Width = 4665
End
Begin VB.CommandButton CmdWork
Caption = "操作"
Height = 465
Left = 1710
TabIndex = 0
Top = 1650
Width = 1095
End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False-------------------------------------但这里~?我只见过VB6~