Python论坛  - 讨论区

标题:[python-chinese] 请问如何在Python中实现将自己的程序加到Windows右键菜单中?

2006年02月18日 星期六 20:18

ajax chelsea ajaxchelsea at gmail.com
Sat Feb 18 20:18:59 HKT 2006

搜了一下没搜到,看Pywin32也好像没有专门的class或function

就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060218/b476c4e6/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月18日 星期六 20:24

Andelf andelf at gmail.com
Sat Feb 18 20:24:39 HKT 2006

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\CMD\command]
@="cmd.exe /k \"cd %L\""
limodou BLOG上的
pywin32有,需要用到注册表


在06-2-18,ajax chelsea <ajaxchelsea at gmail.com> 写道:
>
> 搜了一下没搜到,看Pywin32也好像没有专门的class或function
>
> 就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


--
Andelf
BLOG:http://blog.sohu.com/members/andelf/
BLOG:http://spaces.msn.com/members/andelf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060218/d5a83597/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月18日 星期六 20:35

ajax chelsea ajaxchelsea at gmail.com
Sat Feb 18 20:35:25 HKT 2006

好的;有没有无需直接操作注册表的?

在06-2-18,Andelf <andelf at gmail.com> 写道:
>
> Windows Registry Editor Version 5.00
>
> [HKEY_CLASSES_ROOT\Directory\shell\CMD\command]
> @="cmd.exe /k \"cd %L\""
> limodou BLOG上的
> pywin32有,需要用到注册表
>
>
> 在06-2-18,ajax chelsea <ajaxchelsea at gmail.com> 写道:
> >
> > 搜了一下没搜到,看Pywin32也好像没有专门的class或function
> >
> > 就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
>
> --
> Andelf
> BLOG:http://blog.sohu.com/members/andelf/
> BLOG: http://spaces.msn.com/members/andelf
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060218/2f0e848f/attachment-0001.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月18日 星期六 20:37

Andelf andelf at gmail.com
Sat Feb 18 20:37:47 HKT 2006

不晓得了

在06-2-18,ajax chelsea <ajaxchelsea at gmail.com> 写道:
>
> 好的;有没有无需直接操作注册表的?
>
> 在06-2-18,Andelf <andelf at gmail.com> 写道:
> >
> > Windows Registry Editor Version 5.00
> >
> > [HKEY_CLASSES_ROOT\Directory\shell\CMD\command]
> > @="cmd.exe /k \"cd %L\""
> > limodou BLOG上的
> > pywin32有,需要用到注册表
> >
> >
> > 在06-2-18,ajax chelsea <ajaxchelsea at gmail.com > 写道:
> > >
> > > 搜了一下没搜到,看Pywin32也好像没有专门的class或function
> > >
> > > 就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> >
> >
> > --
> > Andelf
> > BLOG:http://blog.sohu.com/members/andelf/
> > BLOG: http://spaces.msn.com/members/andelf
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


--
Andelf
BLOG:http://blog.sohu.com/members/andelf/
BLOG:http://spaces.msn.com/members/andelf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060218/28a5cf07/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月18日 星期六 20:46

超群李 achilles.lee at gmail.com
Sat Feb 18 20:46:08 HKT 2006

右键菜单肯定是通过注册表实现的。就是注册一种类型给你的程序。可能有专门的windows api来实现。可以查一下msdn.


On 2/18/06, Andelf <andelf at gmail.com> wrote:
>
> 不晓得了
>
> 在06-2-18,ajax chelsea <ajaxchelsea at gmail.com> 写道:
> >
> > 好的;有没有无需直接操作注册表的?
> >
> > 在06-2-18,Andelf <andelf at gmail.com> 写道:
> > >
> > > Windows Registry Editor Version 5.00
> > >
> > > [HKEY_CLASSES_ROOT\Directory\shell\CMD\command]
> > > @="cmd.exe /k \"cd %L\""
> > > limodou BLOG上的
> > > pywin32有,需要用到注册表
> > >
> > >
> > > 在06-2-18,ajax chelsea <ajaxchelsea at gmail.com > 写道:
> > > >
> > > > 搜了一下没搜到,看Pywin32也好像没有专门的class或function
> > > >
> > > > 就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > > >
> > >
> > >
> > > --
> > > Andelf
> > > BLOG:http://blog.sohu.com/members/andelf/
> > > BLOG: http://spaces.msn.com/members/andelf
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
>
> --
> Andelf
> BLOG:http://blog.sohu.com/members/andelf/
> BLOG:http://spaces.msn.com/members/andelf
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


--
李超群
mobile phone:13759961869
office phone:029-87607341
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060218/0954b772/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月18日 星期六 20:49

Andelf andelf at gmail.com
Sat Feb 18 20:49:38 HKT 2006

pywin32的 win32api模块就是调用windows api了,一样
有几个函数是操作注册表的
呃,不知道limodou的NewEdit是怎么实现注册表操作的


在06-2-18,超群李 <achilles.lee at gmail.com> 写道:
>
> 右键菜单肯定是通过注册表实现的。就是注册一种类型给你的程序。可能有专门的windows api来实现。可以查一下msdn.
>
>
> On 2/18/06, Andelf <andelf at gmail.com> wrote:
> >
> > 不晓得了
> >
> > 在06-2-18,ajax chelsea <ajaxchelsea at gmail.com > 写道:
> > >
> > > 好的;有没有无需直接操作注册表的?
> > >
> > > 在06-2-18,Andelf <andelf at gmail.com> 写道:
> > > >
> > > > Windows Registry Editor Version 5.00
> > > >
> > > > [HKEY_CLASSES_ROOT\Directory\shell\CMD\command]
> > > > @="cmd.exe /k \"cd %L\""
> > > > limodou BLOG上的
> > > > pywin32有,需要用到注册表
> > > >
> > > >
> > > > 在06-2-18,ajax chelsea <ajaxchelsea at gmail.com > 写道:
> > > > >
> > > > > 搜了一下没搜到,看Pywin32也好像没有专门的class或function
> > > > >
> > > > > 就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
> > > > >
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese at lists.python.cn
> > > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > >
> > > > > Unsubscribe: send unsubscribe to
> > > > > python-chinese-request at lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Andelf
> > > > BLOG:http://blog.sohu.com/members/andelf/
> > > > BLOG: http://spaces.msn.com/members/andelf
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese at lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request at lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese at lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request at lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> >
> >
> > --
> > Andelf
> > BLOG:http://blog.sohu.com/members/andelf/
> > BLOG:http://spaces.msn.com/members/andelf
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
>
> --
> 李超群
> mobile phone:13759961869
> office phone:029-87607341
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


--
Andelf
BLOG:http://blog.sohu.com/members/andelf/
BLOG:http://spaces.msn.com/members/andelf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060218/afcb9bf6/attachment-0001.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月18日 星期六 20:49

刘鑫 march.liu at gmail.com
Sat Feb 18 20:49:58 HKT 2006

去看一下Limodou的NewEdit源代码,NewEdit实现了这样的功能。

在06-2-18,ajax chelsea <ajaxchelsea at gmail.com> 写道:
>
> 搜了一下没搜到,看Pywin32也好像没有专门的class或function
>
> 就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


--
欢迎访问:
http://blog.csdn.net/ccat

刘鑫
March.Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060218/f07e3a8f/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年02月21日 星期二 21:47

ajax chelsea ajaxchelsea at gmail.com
Tue Feb 21 21:47:00 HKT 2006

从NewEdit源代码中抄了一段,搞定了:
def regFolderContext(prompt, cmdLine):
    import _winreg
    key = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, 'Directory\\shell',
_winreg.KEY_ALL_ACCESS)
    _winreg.SetValue(key, prompt + '\\command', _winreg.REG_SZ, cmdLine)


def unregFolderContext(prompt):
    import _winreg
    try:
       key = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, 'Directory\\shell',
_winreg.KEY_ALL_ACCESS)
        _winreg.DeleteKey(key, prompt + '\\command')
        _winreg.DeleteKey(key, prompt)
    except:
       pass



class FolderContextHelper:
    @staticmethod
    def reg():
        filename = os.path.basename(sys.argv[0])
        f, ext = os.path.splitext(filename)
        if ext == '.exe':
            command = '"%s" "%%1"' % os.path.normpath(sys.argv[0])
        else:
            path = os.path.normpath(sys.argv[0])
            execute = sys.executable.replace('python.exe', 'pythonw.exe')
            command = '"%s" "%s" "%%1"' % (execute, path)

        regFolderContext('PyRename', command)

    @staticmethod
    def unreg():
        unregFolderContext('PyRename')



*PyRename* <http://blog.csdn.net/platformlib/archive/2006/02/11/596863.aspx>
也便增加了右键菜单功能


在06-2-18,刘鑫 <march.liu at gmail.com> 写道:
>
> 去看一下Limodou的NewEdit源代码,NewEdit实现了这样的功能。
>
> 在06-2-18,ajax chelsea <ajaxchelsea at gmail.com> 写道:
> >
> > 搜了一下没搜到,看Pywin32也好像没有专门的class或function
> >
> > 就是如何添加右键菜单(只针对文件夹即可)并将文件夹的路径作为参数传递到自己的程序?
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
>
> --
> 欢迎访问:
> http://blog.csdn.net/ccat
>
> 刘鑫
> March.Liu
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060221/3c20ed55/attachment-0001.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号