好学IT学院:IT信息技术分享交流平台
标签:Delphi  来源:互联网  作者:本站整理  发布时间:2009-05-16  ★★★加入收藏〗〖手机版
摘要: 在自己的界面中弹出系统右键菜单。unit PopupShell;interfaceusesWindows, Messages, SysUtils, StrUtils, ComObj,ShlObj,ActiveX;function Disp……

{  在自己的界面中弹出系统右键菜单。}

unit PopupShell;

interface

uses
  Windows, Messages, SysUtils, StrUtils, ComObj,
  ShlObj,
  ActiveX;

function DisplayContextMenu(const Handle: THandle; const FileName: string;
  Pos: TPoint): Boolean;

implementation

type
  TUnicodePath = array[0..MAX_PATH - 1] of WideChar;

const
  ShenPathSeparator = '\';

//=============================================================================

//返回IDList去掉第一个ItemID后的IDList
  function NextPIDL(IDList: PItemIDList): PItemIDList;
  begin
  Result := IDList;
  Inc(PChar(Result), IDList^.mkid.cb);
  end;

//返回IDList的长度
  function GetPIDLSize(IDList: PItemIDList): Integer;
  begin
  Result := 0;
  if Assigned(IDList) then
  begin
    Result := SizeOf(IDList^.mkid.cb);
    while IDList^.mkid.cb <> 0 do
    begin
      Result := Result + IDList^.mkid.cb;
      IDList := NextPIDL(IDList);
    end;
  end;
  end;

//取得IDList中ItemID的个数
  function GetItemCount(IDList: PItemIDList): Integer;
  begin
  Result := 0;
  while IDList^.mkid.cb <> 0 do
  begin
    Inc(Result);
    IDList := NextPIDL(IDList);
  end;
  end;

//创建一ItemIDList对象
  function CreatePIDL(Size: Integer): PItemIDList;
  var
  Malloc: IMalloc;
  begin
  OleCheck(SHGetMalloc(Malloc));

Result := Malloc.Alloc(Size);
  if Assigned(Result) then
    FillChar(Result^, Size, 0);
  end;

//返回IDList的一个内存拷贝
  function CopyPIDL(IDList: PItemIDList): PItemIDList;
  var
  Size: Integer;
  begin
  Size := GetPIDLSize(IDList);
  Result := CreatePIDL(Size);
  if Assigned(Result) then
    CopyMemory(Result, IDList, Size);
  end;

//返回AbsoluteID最后一个ItemID,即此对象相对于父对象的ItemID
  function RelativeFromAbsolute(AbsoluteID: PItemIDList): PItemIDList;
  begin
  Result := AbsoluteID;
  while GetItemCount(Result) > 1 do
     Result := NextPIDL(Result);
  Result := CopyPIDL(Result);
  end;

//将IDList的最后一个ItemID去掉,即得到IDList的父对象的ItemID
  procedure StripLastID(IDList: PItemIDList);
  var
  MarkerID: PItemIDList;
  begin
  MarkerID := IDList;
  if Assigned(IDList) then
  begin
    while IDList.mkid.cb <> 0 do
    begin
      MarkerID := IDList;
      IDList := NextPIDL(IDList);
    end;
    MarkerID.mkid.cb := 0;
  end;
  end;

微软SQL Server 2008数据库最新版功能介绍
  现今数据的世界里,公司要获得成功和不断发展,他们需要定位了主要的数据趋势的愿景。微软的这个数据平台愿景帮助公司满足这些数据爆炸和下…
  • 好学考试H5触屏版开放内测
  • 好学触屏公众号虎力全开、杨帆起航!