文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>在windows右键菜单中加上关联

在windows右键菜单中加上关联

时间:2011-01-13  来源:梧桐栖凤

uses Registry;

function RegisterFileTypeCommand(fileExtension, menuItemText, target: string) : boolean;
var
  reg: TRegistry;
  fileType: string;
begin
  result := false;
  reg := TRegistry.Create;
  with reg do
  try
    RootKey := HKEY_CLASSES_ROOT;
    if OpenKey('.' + fileExtension, True) then
    begin
      fileType := ReadString('') ;
      if fileType = '' then
      begin
        fileType := fileExtension + 'file';
        WriteString('', fileType) ;
      end;
      CloseKey;
      if OpenKey(fileType + '\shell\' + menuItemText + '\command', True) then
      begin
        WriteString('', target + ' "%1"') ;
        CloseKey;
        result := true;
      end;
    end;
  finally
    Free;
  end;
end;

function UnRegisterFileTypeCommand(fileExtension, menuItemText: string) : boolean;
var
  reg: TRegistry;
  fileType: string;
begin
  result := false;
  reg := TRegistry.Create;
  with reg do
  try
    RootKey := HKEY_CLASSES_ROOT;
    if OpenKey('.' + fileExtension, True) then
    begin
      fileType := ReadString('') ;
      CloseKey;
    end;
    if OpenKey(fileType + '\shell', True) then
    begin
      DeleteKey(menuItemText) ;
      CloseKey;
      result := true;
    end;
  finally
    Free;
  end;
end;

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/sunstone/archive/2009/10/22/4715097.aspx

相关阅读 更多 +
排行榜 更多 +
宝宝欢乐农场

宝宝欢乐农场

休闲益智 下载
我的世界外进神器

我的世界外进神器

游戏工具 下载
飞虎队模拟器2

飞虎队模拟器2

飞行射击 下载