有谁知道Jbuilder8中的Jdatastore的序列号 (200分)

  • 主题发起人 主题发起人 humanc2d4
  • 开始时间 开始时间
H

humanc2d4

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp;关键是加图标,比如我在右键上加一个菜单为‘我的菜单’,怎样在‘我的菜单’<br>前加一个图标。最好有源程序![8D]
 
只要修改一下注册表就行了,<br>你可以下载一个注册表的帮助就行了<br>http://download.pchome.net/php/dl.php?sid=11838
 
下载一个 《注册表实用手册》
 
我写的程序如下:<br>Contextmenuhandle.pas,将Form保存为<br>OpWindow.pas。<br>Contextmenu.dpr的程序清单如下:<br>library contextmenu;<br>&nbsp; &nbsp; uses<br>&nbsp; ComServ,<br>&nbsp; contextmenuhandle in 'contextmenuhandle.pas',<br>&nbsp; opwindow in 'opwindow.pas' {Form2};<br><br>exports<br>&nbsp; &nbsp;DllGetClassObject,<br>&nbsp; &nbsp;DllCanUnloadNow,<br>&nbsp; &nbsp;DllRegisterServer,<br>&nbsp; &nbsp;DllUnregisterServer;<br><br>{$R *.TLB}<br><br>{$R *.RES}<br><br>begin<br><br>end.<br><br>&nbsp; &nbsp; Contextmenuhandle的程序清单如下:<br>unit ContextMenuHandle;<br><br>interface<br>&nbsp; &nbsp;uses Windows,ActiveX,ComObj,ShlObj,Classes;<br><br>type<br>&nbsp; &nbsp;TContextMenu = class(TComObject,IShellExtInit,IContextMenu)<br>&nbsp; &nbsp;private<br>&nbsp; &nbsp; &nbsp; FFileName: array[0..MAX_PATH] of Char;<br>&nbsp; &nbsp;protected<br>&nbsp; &nbsp; &nbsp; function IShellExtInit.Initialize = SEIInitialize; // Avoid compiler warning<br>&nbsp; &nbsp; &nbsp; function SEIInitialize(pidlFolder: PItemIDList; lpdobj: IDataObject;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hKeyProgID: HKEY): HResult; stdcall;<br>&nbsp; &nbsp; &nbsp; function QueryContextMenu(Menu: HMENU; indexMenu, idCmdFirst, idCmdLast,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uFlags: UINT): HResult; stdcall;<br>&nbsp; &nbsp; &nbsp; function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult; stdcall;<br>&nbsp; &nbsp; &nbsp; function GetCommandString(idCmd, uType: UINT; pwReserved: PUINT;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pszName: LPSTR; cchMax: UINT): HResult; stdcall;<br>end;<br><br>const<br><br>&nbsp; &nbsp;Class_ContextMenu: TGUID = '{19741013-C829-11D1-8233-0020AF3E97A0}';<br><br>{全局唯一标识符(GUID)是一个16字节(128为)的值,它唯一地标识一个接口(interface)}<br>var<br>&nbsp; &nbsp;FileList:TStringList;<br><br><br>implementation<br><br>uses ComServ, SysUtils, ShellApi, Registry,UnitForm;<br><br>function TContextMenu.SEIInitialize(pidlFolder: PItemIDList; lpdobj: IDataObject;<br>&nbsp; &nbsp;hKeyProgID: HKEY): HResult;<br>var<br>&nbsp; &nbsp;StgMedium: TStgMedium;<br>&nbsp; &nbsp;FormatEtc: TFormatEtc;<br>&nbsp; &nbsp;FileNumber,i:Integer;<br>begin<br>&nbsp; &nbsp;file://如/果lpdobj等于Nil,则本调用失败<br>&nbsp; &nbsp;if (lpdobj = nil) then begin<br>&nbsp; &nbsp; &nbsp; Result := E_INVALIDARG;<br>&nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp;end;<br><br>&nbsp; &nbsp;file://首/先初始化并清空FileList以添加文件<br>&nbsp; &nbsp;FileList:=TStringList.Create;<br>&nbsp; &nbsp;FileList.Clear;<br>&nbsp; &nbsp;file://初/始化剪贴版格式文件<br>&nbsp; &nbsp;with FormatEtc do begin<br>&nbsp; &nbsp; &nbsp; cfFormat := CF_HDROP;<br>&nbsp; &nbsp; &nbsp; ptd := nil;<br>&nbsp; &nbsp; &nbsp; dwAspect := DVASPECT_CONTENT;<br>&nbsp; &nbsp; &nbsp; lindex := -1;<br>&nbsp; &nbsp; &nbsp; tymed := TYMED_HGLOBAL;<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp;Result := lpdobj.GetData(FormatEtc, StgMedium);<br><br>&nbsp; &nbsp;if Failed(Result) then Exit;<br><br>&nbsp; &nbsp;file://首/先查询用户选中的文件的个数<br>&nbsp; &nbsp;FileNumber := DragQueryFile(StgMedium.hGlobal,$FFFFFFFF,nil,0);<br>&nbsp; &nbsp;file://循/环读取,将所有用户选中的文件保存到FileList中<br>&nbsp; &nbsp;for i:=0 to FileNumber-1 do begin<br>&nbsp; &nbsp; &nbsp; DragQueryFile(StgMedium.hGlobal, i, FFileName, SizeOf(FFileName));<br>&nbsp; &nbsp; &nbsp; FileList.Add(FFileName);<br>&nbsp; &nbsp; &nbsp; Result := NOERROR;<br>&nbsp; &nbsp;end;<br><br>&nbsp; &nbsp;ReleaseStgMedium(StgMedium);<br>end;<br><br>function TContextMenu.QueryContextMenu(Menu: HMENU; indexMenu, idCmdFirst,<br>&nbsp; &nbsp;idCmdLast, uFlags: UINT): HResult;<br>begin<br>&nbsp; Result := 0;<br>&nbsp; if ((uFlags and $0000000F) = CMF_NORMAL) or<br>&nbsp; &nbsp; &nbsp;((uFlags and CMF_EXPLORE) &lt;&gt; 0) then begin<br>&nbsp; &nbsp; // 往Context Menu中加入一个菜单项 ,菜单项的标题为察看位图文件<br>&nbsp; &nbsp; InsertMenu(Menu, indexMenu, MF_STRING or MF_BYPOSITION, idCmdFirst,<br>&nbsp; &nbsp; &nbsp; &nbsp; PChar('文件操作'));<br>&nbsp; &nbsp; // 返回增加菜单项的个数<br>&nbsp; &nbsp; Result := 1;<br>&nbsp; end;<br>end;<br><br>function TContextMenu.InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult;<br>var<br>&nbsp; frmOP:TForm1;<br>begin<br>&nbsp; // 首先确定该过程是被系统而不是被一个程序所调用<br>&nbsp; if (HiWord(Integer(lpici.lpVerb)) &lt;&gt; 0) then<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp;Result := E_FAIL;<br>&nbsp; &nbsp; &nbsp;Exit;<br>&nbsp; end;<br>&nbsp; // 确定传递的参数的有效性<br>&nbsp; if (LoWord(lpici.lpVerb) &lt;&gt; 0) then begin<br>&nbsp; &nbsp; &nbsp;Result := E_INVALIDARG;<br>&nbsp; &nbsp; &nbsp;Exit;<br>&nbsp; end;<br><br>&nbsp; &nbsp;file://建/立文件操作窗口<br>&nbsp; frmOP:=TForm1.Create(nil);<br>&nbsp; file://将/所有的文件列表添加到文件操作窗口的列表中<br>&nbsp; frmOP.ListBox1.Items := FileList;<br>&nbsp; Result := NOERROR;<br>end;<br><br><br>function TContextMenu.GetCommandString(idCmd, uType: UINT; pwReserved: PUINT;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pszName: LPSTR; cchMax: UINT): HRESULT;<br>begin<br>&nbsp; &nbsp;if (idCmd = 0) then begin<br>&nbsp; &nbsp;if (uType = GCS_HELPTEXT) then<br>&nbsp; &nbsp; &nbsp; {返回该菜单项的帮助信息,此帮助信息将在用户把鼠标<br>&nbsp; &nbsp; &nbsp; 移动到该菜单项时出现在状态条上。}<br>&nbsp; &nbsp; &nbsp; StrCopy(pszName, PChar('点击该菜单项将执行文件操作'));<br>&nbsp; &nbsp; &nbsp; Result := NOERROR;<br>&nbsp; &nbsp;end<br>&nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; Result := E_INVALIDARG;<br>end;<br><br>type<br>&nbsp; &nbsp;TContextMenuFactory = class(TComObjectFactory)<br>&nbsp; &nbsp;public<br>&nbsp; &nbsp;procedure UpdateRegistry(Register: Boolean); override;<br>end;<br><br>procedure TContextMenuFactory.UpdateRegistry(Register: Boolean);<br>var<br>&nbsp; &nbsp;ClassID: string;<br>begin<br>&nbsp; &nbsp;if Register then begin<br>&nbsp; &nbsp; &nbsp; inherited UpdateRegistry(Register);<br>&nbsp; &nbsp; &nbsp; ClassID := GUIDToString(Class_ContextMenu);<br>&nbsp; &nbsp; &nbsp; file://当/注册扩展库文件时,添加库到注册表中<br>&nbsp; &nbsp; &nbsp; CreateRegKey('*/shellex', '', '');<br>&nbsp; &nbsp; &nbsp; CreateRegKey('*/shellex/ContextMenuHandlers', '', '');<br>&nbsp; &nbsp; &nbsp; CreateRegKey('*/shellex/ContextMenuHandlers/FileOpreation', '', ClassID);<br><br>&nbsp; &nbsp; file://如/果操作系统为Windows NT的话<br>&nbsp; &nbsp; &nbsp; if (Win32Platform = VER_PLATFORM_WIN32_NT) then<br>&nbsp; &nbsp; &nbsp; with TRegistry.Create do<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RootKey := HKEY_LOCAL_MACHINE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OpenKey('SOFTWARE/Microsoft/Windows/CurrentVersion/Shell Extensions', True);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OpenKey('Approved', True);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WriteString(ClassID, 'Context Menu Shell Extension');<br>&nbsp; &nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Free;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp;end<br>&nbsp; &nbsp;else begin<br>&nbsp; &nbsp; &nbsp; DeleteRegKey('*/shellex/ContextMenuHandlers/FileOpreation');<br>&nbsp; &nbsp; &nbsp; inherited UpdateRegistry(Register);<br>&nbsp; &nbsp;end;<br>end;<br><br>&nbsp;<br><br>initialization<br>&nbsp;TContextMenuFactory.Create(ComServer, TContextMenu, Class_ContextMenu,<br>&nbsp; &nbsp;'', 'Context Menu Shell Extension', ciMultiInstance,tmApartment);<br><br>end.<br><br><br>&nbsp; &nbsp; 在OpWindow窗口中加入一个TListBox控件和两个TButton控件,OpWindows.pas的程序清单如下:<br>unit opwindow;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; ExtCtrls, StdCtrls,shlobj,shellapi,ActiveX;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; ListBox1: TListBox;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure FormClose(Sender: TObject; var Action: TCloseAction);<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; FileList:TStringList;<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; &nbsp;Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; FileList:=TStringList.Create;<br>&nbsp; Button1.Caption :='复制文件';<br>&nbsp; Button2.Caption :='移动文件';<br>&nbsp; Self.Show;<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>&nbsp; FileList.Free;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; sPath:string;<br>&nbsp; fsTemp:SHFILEOPSTRUCT;<br>&nbsp; i:integer;<br>begin<br>&nbsp; sPath:=InputBox('文件操作','输入复制路径','c:/windows');<br>&nbsp; if sPath&lt;&gt;''then begin<br>&nbsp; &nbsp; fsTemp.Wnd := Self.Handle;<br>&nbsp; &nbsp; file://设/置文件操作类型<br>&nbsp; &nbsp; fsTemp.wFunc :=FO_COPY;<br>&nbsp; &nbsp; file://允/许执行撤消操作<br>&nbsp; &nbsp; fsTemp.fFlags :=FOF_ALLOWUNDO;<br>&nbsp; &nbsp; for i:=0 to ListBox1.Items.Count-1 do begin<br>&nbsp; &nbsp; &nbsp; file://源/文件全路径名<br>&nbsp; &nbsp; &nbsp; fsTemp.pFrom := PChar(ListBox1.Items.Strings);<br>&nbsp; &nbsp; &nbsp; file://要/复制到的路径<br>&nbsp; &nbsp; &nbsp; fsTemp.pTo := PChar(sPath);<br>&nbsp; &nbsp; &nbsp; fsTemp.lpszProgressTitle:='拷贝文件';<br>&nbsp; &nbsp; &nbsp; if SHFileOperation(fsTemp)&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; ShowMessage('文件复制失败');<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; sPath:string;<br>&nbsp; fsTemp:SHFILEOPSTRUCT;<br>&nbsp; i:integer;<br>begin<br>&nbsp; sPath:=InputBox('文件操作','输入移动路径','c:/windows');<br>&nbsp; if sPath&lt;&gt;''then begin<br>&nbsp; &nbsp; fsTemp.Wnd := Self.Handle;<br>&nbsp; &nbsp; fsTemp.wFunc :=FO_MOVE;<br>&nbsp; &nbsp; fsTemp.fFlags :=FOF_ALLOWUNDO;<br>&nbsp; &nbsp; for i:=0 to ListBox1.Items.Count-1 do begin<br>&nbsp; &nbsp; &nbsp; fsTemp.pFrom := PChar(ListBox1.Items.Strings);<br>&nbsp; &nbsp; &nbsp; fsTemp.pTo := PChar(sPath);<br>&nbsp; &nbsp; &nbsp; fsTemp.lpszProgressTitle:='移动文件';<br>&nbsp; &nbsp; &nbsp; if SHFileOperation(fsTemp)&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; ShowMessage('文件复制失败');<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>end.<br><br>我在windows右键菜单中加'文件操作'关键是怎样加在文件操作前加图标,象winrar或winzip一样!
 
如果你的机器上装有WINRAR,查看注册表中 <br>HKEY_CLASSES_ROOT/*<br>HKEY_CLASSES_ROOT/.RAR<br>HKEY_CLASSES_ROOT/WINRAR/<br>下的设置。<br>然后实用REGISTRY类实现协注册表。<br>
 
用popupmenu和imagelist实现<br>为imagelist添加多个图标,<br>将popupmenu的images属性设为imagelist<br>并为每个子菜单设置imageindex属性<br>这样就可以了
 
我做的是conentmenu也就是windows上下文菜单。<br>比如在windows桌面上有一个名为readme.txt文件,我在readme.txt文件上单击鼠标右键,<br>在windows鼠标右键的基础上加上了我的菜单项,单击我的菜单后会执行我的一段程序(<br>比如:把readme.txt文件直接发送电子邮件)。其实就是我们常用的winzip或winrar工具。<br>我现在基本上快完成了,就是不知道怎样在我的菜单项上加入图片。<br>
 
我也想知道
 
太难了![:(]
 
呵呵,想的太简单了<br>关注
 
呵呵,关注~~<br>up
 
<br><br>ModifyMenu(menuhandle, &nbsp;... &nbsp;,MF_BITMAP,....<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ///////// &nbsp;
 
请jsxjd高手写详细一点,我将200分全部献上。我的邮件是humanyixiaobing@163.com
 
加菜单比较简单,但是加图标就不容易,<br>好像比较好的办法就是编一Dll,注册Com,Delphi Demos里有介绍。<br>WinZip,WinRar,金山毒霸等都是用的这种方法。
 
可我用的就是delphi+com,也就是delphi中demo中的例子。但例子中没有介绍加图标[?]
 
有人能给我解答吗?[:)]
 
真的没人会吗?[:)]
 
我写的ShellExpress组件包可以帮助你添加图标到右键菜单上<br>http://hubdog.myrice.com
 
后退
顶部