网上查了下资料,win7下为了让程序显示UAC标志,可以加入一个下面的文件 UAC.manifest 做成的uac.res,并在程序里面加入{$R uac.res} <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
按照这个步骤做完之后,WM_DROPFILES消息居然无法捕捉,文件的拖放功能也相应失效。
上网找了很多资料,都说用ChangeWindowMessageFilter函数,可以将WM_DROPFILES相关消息都从过滤器中剔出,试了下仍然没有效果。值得一提的是,如果把这个资源去掉了,程序在win7跑的时候不再跳出UAC提示,文件拖放的功能反而有效了,跟预期的效果一样。请各位讨论指点。
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
按照这个步骤做完之后,WM_DROPFILES消息居然无法捕捉,文件的拖放功能也相应失效。
上网找了很多资料,都说用ChangeWindowMessageFilter函数,可以将WM_DROPFILES相关消息都从过滤器中剔出,试了下仍然没有效果。值得一提的是,如果把这个资源去掉了,程序在win7跑的时候不再跳出UAC提示,文件拖放的功能反而有效了,跟预期的效果一样。请各位讨论指点。
ChangeWindowMessageFilter (WM_COPYDATA, MSGFLT_ADD);
ChangeWindowMessageFilter (0x0049, MSGFLT_ADD);
function runwin7: Boolean;
const
MSGFLT_ADD = 1;
var
ChangeWindowMessageFilter: function(msg: Cardinal; dwFlag: Word): BOOL; stdcall;
begin
@ChangeWindowMessageFilter := GetProcAddress(LoadLibrary('user32.dll'), 'ChangeWindowMessageFilter'); if @ChangeWindowMessageFilter <> nil then try
// ChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD);
// ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
ChangeWindowMessageFilter(SPI_SETANIMATION, MSGFLT_ADD);
except end;
end;FormCreate里面调用:
runwin7;