好学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;

数据库指南:关于DB2常用技巧解析
  DB2数据库操作是开发人员经常接触到的,是我们最常用的数据库之一,下面就教您一个DB2删除数据时的小技巧,如果您对DB2删除数据方…
  • 好学考试H5触屏版开放内测
  • 好学触屏公众号虎力全开、杨帆起航!