下面是一段delphi代码,你在c# 中引入api 即可

procedure TForm1.Button1Click(Sender: TObject);
var
i:HWND;
cs:CREATESTRUCT;
begin
// i := FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil);
i := FindWindow('Shell_TrayWnd', nil);//这里可以通过FindWindowEx找到开始按钮,并得到他的按钮区域( GetWindowRect ),并以此来指定新按钮的区域
cs.lpszClass:= 'Button';
cs.lpszName:= '我的按钮';
cs.style:= WS_CHILD or WS_VISIBLE or WS_BORDER;
cs.hMenu:= 0;
cs.hwndParent:= i;
cs.lpCreateParams:= nil;
cs.x:= 100;
cs.y:= 0;
cs.cx:= 20;
cs.cy:= 30;
cs.hInstance:= 0;
i := CreateWindow(cs.lpszClass,
cs.lpszName,
cs.style,
cs.x,
cs.y,
cs.cx,
cs.cy,
cs.hwndParent,
cs.hMenu,
cs.hInstance,
cs.lpCreateParams);
end;

原文地址:https://www.cnblogs.com/blogpro/p/11446564.html