473,497 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SetWindowLong failed with 'Access is denied' when invoked from a windows service

1 New Member
the P/Invoke SetWindowLong failed with 'Access is denied' when invoked from a windows service.
The service runs under the System account with the 'allow user to interact with the desktop' checked.
If I have the same code executed from a regular user app it works just fine.
Other P/Invoke calls from the windows service are just fine under the system account like: IsIconic, GetWindowRect, PrintWindow, GetClientRect, CreateCompatibleDC, CreateCompatibleBitmap, SelectObject, etc.
So far only SetWindowLong fails in the code below when under system acccount in the service:
Expand|Select|Wrap|Line Numbers
  1.  
  2. [DllImport("user32", SetLastError = true)]
  3. internal static extern int SetWindowLong(IntPtr hWnd, int index, int dwNewLong);
  4. //......hWnd is some window on the local desktop
  5. int res = SetWindowLong(hWnd, GWL_EXSTYLE, winLong | WS_EX_LAYERED);
  6. if (res != winLong)
  7.                 {
  8.                     Win32Exception ex = new Win32Exception(Marshal.GetLastWin32Error());
  9.                     throw new ApplicationException("SetWindowLong failed: " + ex.Message, ex);//fails in win service, not regular app
  10.                 }
Trying to impersonate the logged on user did not work either.
Any ideeas how to get arround?
Oct 19 '07 #1
0 1957

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2888
by: Steve Jorgensen | last post by:
I know quite well that this question falls into the category of "why does Access misbehave when I do unexpected things to its objects?", but I thought I'd ask anyway, and see if anyone knows. ...
0
2075
by: Jeff Reed | last post by:
I am experiencing the the problem outlined the below. Unfortunately, I am using WinXP and I not sure if I can apply the solution due to lack of security control Any feed back would be apreciated ...
9
3183
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
4
2897
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
1
9462
by: Rachel | last post by:
I have created a simple web service in VC# that adds two numbers. It returns an integer value to the client once invoked. I used Visual Studio .NET 2003, Windows XP Pro and .NET 1.1. I created a...
3
7943
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
1
4335
by: amit.vasu | last post by:
Hi I have created a web serivces using .net framework 2.0. When I try to execute the web service I get the following error. Failed to start monitoring changes to 'e:\Default Web Site' because...
6
5543
by: royan | last post by:
Help please! I have the same problem which this post ...
5
9078
by: tyakimov | last post by:
Hi guys I got a problem On my IIS server I changed the password for the Internet Guest Account 'IUSR_Machine' and suddenly the PHP part of the intranet stopped working. - '... failed to open...
0
7120
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.