VISTA 低权限程序向高权限程序发消息

procedureRunAsAdmin(hWnd:HWND;aFile:string;aParameters:string);varsei:TShellExecuteInfoA;beginFillChar(sei,SizeOf(sei),0);sei.cbSize:=SizeOf(sei);sei.Wnd:=hWnd;sei.fMask:=SEE_MASK_FLAG_DDEWAITorSEE_MASK_FLAG_NO_UI;sei.lpVerb:=


需要在高权限程序开始的地方加入以下代码,指定什么消息可以接受

typedef BOOL (WINAPI *_ChangeWindowMessageFilter)( UINT , DWORD);

BOOL CVistaMsgRecvApp::AllowMeesageForVista(UINT uMessageID, BOOL bAllow)//注册Vista全局消息

{

     BOOL bResult = FALSE;

     HMODULE hUserMod = NULL;

 

     //vista and later

     hUserMod = LoadLibrary( L"user32.dll" );

     if( NULL == hUserMod )

     {

         return FALSE;

     }

 

     _ChangeWindowMessageFilter pChangeWindowMessageFilter = (_ChangeWindowMessageFilter)GetProcAddress( hUserMod, "ChangeWindowMessageFilter" );

 

     if( NULL == pChangeWindowMessageFilter )

     {

         AfxMessageBox(_T("create windowmessage filter failed"));

         return FALSE;

     }

 

     bResult = pChangeWindowMessageFilter( uMessageID, bAllow ? 1 : 2 );//MSGFLT_ADD: 1, MSGFLT_REMOVE: 2

 

     if( NULL != hUserMod )

     {

         FreeLibrary( hUserMod );

     }

 

     return bResult;

}


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/EddieJam/archive/2009/07/14/4348715.aspx

你可能感兴趣的:(VISTA 低权限程序向高权限程序发消息)