본문 바로가기
Delphi 문제점 Tip

UAC Windows10 Drag & Drop 윈도우메세지

by MonoSoft 2022. 4. 26.
728x90
반응형

UAC Windows10 Drag & Drop 윈도우메세지 

 


추가

procedure TF_Thermal_burn_Save.SetDragAndDropOnSystemsWIthUAC(Wnd: HWND; IsEnabled: boolean);

type

TChangeWindowMessageFilter = function(Msg : Cardinal; Action : Word):Bool; stdcall;

const

Msg_Add = 1;

WM_COPYGLOBALDATA = $49;

var

DllHandle : THandle;

ChangeWindowMessageFilter : TChangeWindowMessageFilter;

begin

DllHandle := LoadLibrary('user32.dll');

if DllHandle > 0 then

begin

ChangeWindowMessageFilter := GetProcAddress(DllHandle, 'ChangeWindowMessageFilter');

if Assigned(ChangeWindowMessageFilter) then

begin

DragAcceptFiles(Wnd,IsEnabled);

ChangeWindowMessageFilter(WM_DROPFILES,Msg_Add);

ChangeWindowMessageFilter(WM_COPYGLOBALDATA,Msg_Add);

end;

end;

end;

 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

SetDragAndDropOnSystemsWIthUAC(Self.Handle,False);

end;

 

procedure TForm1.FormCreate(Sender: TObject);

begin

SetDragAndDropOnSystemsWIthUAC(Self.Handle,True);

end;

 


관련참고링크: https://kindsr.pe.kr/207

프로그램이 관리자권한으로 실행 모드로 실행되었다면 WM_DROPFILES

메세지가 정상 수신처리 되지 않습니다.

이경우는 User.DLL에 있는 ChangeWindowMessageFilter API함수로

해당 관련 메세지를 수신받겠다는 선언을 해주시면 됩니다.

 

formCreate하는부분에

ChangeWindowMessageFilter (WM_DROPFILES, MSGFLT_ADD);

ChangeWindowMessageFilter (WM_COPYDATA, MSGFLT_ADD);

ChangeWindowMessageFilter (0x0049, MSGFLT_ADD); 

를 넣어주면 됩니다.

 

단 윈도우 XP까지 지원하게 만드려면 user.dll에서

ChangeWindowMessageFilter 함수를 호출 안하게 해주면 됩니다.

XP에는 ChangeWindowMessageFilter 함수가 없습니다.


https://crowback.tistory.com/247  

 

UAC Drag & Drop

안녕하세요. 까막입니다. UAC 관련하여 최근 작업을 진행하면서 찾은 자료를 공유해보고자 올려봅니다. 문제 : UAC 상에서 관리자 권한으로 상승 시킨 어플리케이션과 탐색기 간의 Drag & Drop 가 동

crowback.tistory.com

 

DragAndDropWithUAC.7z
0.01MB

728x90
반응형

댓글