K
kijato993
Guest
Hi,
I'm having an issue with my application when trying to gain focus on my dialog via the use of SetForegroundWindow and AttachThreadInput. AttachThreadInput failed with error code 5 ("access denied") from process having standard privilege.
My application is running under standard user privileges while another application ( say a notepad, just for an example) with the admin user privilege is running at the foreground.
The following is code what goes on at the end of my OnInitDialog function;
DWORD dwForeProcessId;
DWORD dwForeThreadId = ::GetWindowThreadProcessId:GetForegroundWindow(), &dwForeProcessId);
DWORD dwCurrThreadID = ::GetCurrentThreadId();
if (!::AttachThreadInput(dwForeThreadId, dwCurrThreadID, TRUE))
{
//AttachThreadInput fails with an exit code of 5 here.
TRACE(_T("AttachThreadInput failed on TRUE!! : Error code : %d"), ::GetLastError());
//return FALSE ;
}
//::BringWindowToTop(m_hWnd);
//::ShowWindow(m_hWnd, SW_SHOW);
if (!::SetForegroundWindow(m_hWnd))
{
TRACE(_T("SetForegroundWindow failed!! : Error code : %d"), ::GetLastError());
//return FALSE;
}
if (!::AttachThreadInput(dwForeThreadId, dwCurrThreadID, FALSE))
{
//AttachThreadInput fails with an exit code of 5 here.
TRACE(_T("AttachThreadInput failed on FALSE!! : Error code : %d"), ::GetLastError());
//return FALSE ;
}
Any help would be much appreciated...
Continue reading...
I'm having an issue with my application when trying to gain focus on my dialog via the use of SetForegroundWindow and AttachThreadInput. AttachThreadInput failed with error code 5 ("access denied") from process having standard privilege.
My application is running under standard user privileges while another application ( say a notepad, just for an example) with the admin user privilege is running at the foreground.
The following is code what goes on at the end of my OnInitDialog function;
DWORD dwForeProcessId;
DWORD dwForeThreadId = ::GetWindowThreadProcessId:GetForegroundWindow(), &dwForeProcessId);
DWORD dwCurrThreadID = ::GetCurrentThreadId();
if (!::AttachThreadInput(dwForeThreadId, dwCurrThreadID, TRUE))
{
//AttachThreadInput fails with an exit code of 5 here.
TRACE(_T("AttachThreadInput failed on TRUE!! : Error code : %d"), ::GetLastError());
//return FALSE ;
}
//::BringWindowToTop(m_hWnd);
//::ShowWindow(m_hWnd, SW_SHOW);
if (!::SetForegroundWindow(m_hWnd))
{
TRACE(_T("SetForegroundWindow failed!! : Error code : %d"), ::GetLastError());
//return FALSE;
}
if (!::AttachThreadInput(dwForeThreadId, dwCurrThreadID, FALSE))
{
//AttachThreadInput fails with an exit code of 5 here.
TRACE(_T("AttachThreadInput failed on FALSE!! : Error code : %d"), ::GetLastError());
//return FALSE ;
}
Any help would be much appreciated...
Continue reading...