473,837 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing shared network drives prevents standby mode

JT
Hi,

I've realized that my good fortune of not having my computer go into
standby mode was the result of my application accessing a file on a
shared network drive. Not going into standby is a very good thing for
my application, but I don't want users to be required to share a drive
and file just to accomplish this.

I've read in old posts in various places stating that by importing
kernel32.dll I could access a function called
SetThreadExecut ionState(...) with a value of ES_SYSTEM_REQUI RED,
potentially ORed with ES_CONTINUOUS (or the equivalent DWORD values),
would accomplish what I need. I'm guessing this is not managed code
and would have to be marshalled in and used as unsafe code (please
forgive me for not knowing anything about marshalling or unmanaged
code).

Is there a managed code way to accomplish this? Does anyone have any
suggestions?

Thanks,

JT
Feb 18 '08 #1
6 2279
JT,

You ^might^ be able to do this through the WMI provider for windows,
which means you would access the System.Manageme nt namespace, but to be
honest, doing it through the P/Invoke layer is ^not^ that big of a deal.
The declaration for the function is at:

http://www.pinvoke.net/default.aspx/...tionState.html

Also, you don't need unsafe code to call this. But a call through the
P/Invoke layer is required. In this case though, it's trivial. Some
sections of the .NET framework are completely reliant on the P/Invoke layer
(pretty much everything in the System.Windows. Forms namespace).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"JT" <jt@onemain.com wrote in message
news:a6******** *************** ***********@e6g 2000prf.googleg roups.com...
Hi,

I've realized that my good fortune of not having my computer go into
standby mode was the result of my application accessing a file on a
shared network drive. Not going into standby is a very good thing for
my application, but I don't want users to be required to share a drive
and file just to accomplish this.

I've read in old posts in various places stating that by importing
kernel32.dll I could access a function called
SetThreadExecut ionState(...) with a value of ES_SYSTEM_REQUI RED,
potentially ORed with ES_CONTINUOUS (or the equivalent DWORD values),
would accomplish what I need. I'm guessing this is not managed code
and would have to be marshalled in and used as unsafe code (please
forgive me for not knowing anything about marshalling or unmanaged
code).

Is there a managed code way to accomplish this? Does anyone have any
suggestions?

Thanks,

JT
Feb 18 '08 #2
JT
Thanks Nicholas,

Before my first post I did a quick scan through WMI, and quickly got
lost, never having looked at it before, but I didn't see anything
relating to what I need. I will go look at your link and investigate
P/Invoke. I've never dealt with that either.

JT

On Feb 18, 11:48*am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
JT,

* * You ^might^ be able to do this through the WMI provider for windows,
which means you would access the System.Manageme nt namespace, but to be
honest, doing it through the P/Invoke layer is ^not^ that big of a deal.
The declaration for the function is at:

http://www.pinvoke.net/default.aspx/...ExecutionState....

* * Also, you don't need unsafe code to call this. *But a call through the
P/Invoke layer is required. *In this case though, it's trivial. *Some
sections of the .NET framework are completely reliant on the P/Invoke layer
(pretty much everything in the System.Windows. Forms namespace).

--
* * * * * - Nicholas Paldino [.NET/C# MVP]
* * * * * - m...@spam.guard .caspershouse.c om

"JT" <j...@onemain.c omwrote in message

news:a6******** *************** ***********@e6g 2000prf.googleg roups.com...
Hi,
I've realized that my good fortune of not having my computer go into
standby mode was the result of my application accessing a file on a
shared network drive. *Not going into standby is a very good thing for
my application, but I don't want users to be required to share a drive
and file just to accomplish this.
I've read in old posts in various places stating that by importing
kernel32.dll I could access a function called
SetThreadExecut ionState(...) with a value of ES_SYSTEM_REQUI RED,
potentially ORed with ES_CONTINUOUS (or the equivalent DWORD values),
would accomplish what I need. *I'm guessing this is not managed code
and would have to be marshalled in and used as unsafe code (please
forgive me for not knowing anything about marshalling or unmanaged
code).
Is there a managed code way to accomplish this? *Does anyone have any
suggestions?
Thanks,
JT- Hide quoted text -

- Show quoted text -
Feb 18 '08 #3
JT
Nicholas,

I just did my first P/Invoke and it works like a champ (on preliminary
evaluation)! Are there any caveats about P/Invokes?

Thanks,

JT

On Feb 18, 12:07*pm, JT <j...@onemain.c omwrote:
Thanks Nicholas,

Before my first post I did a quick scan through WMI, and quickly got
lost, never having looked at it before, but I didn't see anything
relating to what I need. *I will go look at your link and investigate
P/Invoke. *I've never dealt with that either.

JT

On Feb 18, 11:48*am, "Nicholas Paldino [.NET/C# MVP]"

<m...@spam.guar d.caspershouse. comwrote:
JT,
* * You ^might^ be able to do this through the WMI provider for windows,
which means you would access the System.Manageme nt namespace, but to be
honest, doing it through the P/Invoke layer is ^not^ that big of a deal.
The declaration for the function is at:
http://www.pinvoke.net/default.aspx/...ExecutionState....
* * Also, you don't need unsafe code to call this. *But a call through the
P/Invoke layer is required. *In this case though, it's trivial. *Some
sections of the .NET framework are completely reliant on the P/Invoke layer
(pretty much everything in the System.Windows. Forms namespace).
--
* * * * * - Nicholas Paldino [.NET/C# MVP]
* * * * * - m...@spam.guard .caspershouse.c om
"JT" <j...@onemain.c omwrote in message
news:a6******** *************** ***********@e6g 2000prf.googleg roups.com...
Hi,
I've realized that my good fortune of not having my computer go into
standby mode was the result of my application accessing a file on a
shared network drive. *Not going into standby is a very good thing for
my application, but I don't want users to be required to share a drive
and file just to accomplish this.
I've read in old posts in various places stating that by importing
kernel32.dll I could access a function called
SetThreadExecut ionState(...) with a value of ES_SYSTEM_REQUI RED,
potentially ORed with ES_CONTINUOUS (or the equivalent DWORD values),
would accomplish what I need. *I'm guessing this is not managed code
and would have to be marshalled in and used as unsafe code (please
forgive me for not knowing anything about marshalling or unmanaged
code).
Is there a managed code way to accomplish this? *Does anyone have any
suggestions?
Thanks,
JT- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
Feb 18 '08 #4
Keep in mind that calling this API doesn't prevent a *user* to put the
system in Sleep state.

Willy.
"JT" <jt@onemain.com wrote in message
news:94******** *************** ***********@d4g 2000prg.googleg roups.com...
Nicholas,

I just did my first P/Invoke and it works like a champ (on preliminary
evaluation)! Are there any caveats about P/Invokes?

Thanks,

JT

On Feb 18, 12:07 pm, JT <j...@onemain.c omwrote:
Thanks Nicholas,

Before my first post I did a quick scan through WMI, and quickly got
lost, never having looked at it before, but I didn't see anything
relating to what I need. I will go look at your link and investigate
P/Invoke. I've never dealt with that either.

JT

On Feb 18, 11:48 am, "Nicholas Paldino [.NET/C# MVP]"

<m...@spam.guar d.caspershouse. comwrote:
JT,
You ^might^ be able to do this through the WMI provider for windows,
which means you would access the System.Manageme nt namespace, but to be
honest, doing it through the P/Invoke layer is ^not^ that big of a deal.
The declaration for the function is at:
http://www.pinvoke.net/default.aspx/...ExecutionState....
Also, you don't need unsafe code to call this. But a call through the
P/Invoke layer is required. In this case though, it's trivial. Some
sections of the .NET framework are completely reliant on the P/Invoke
layer
(pretty much everything in the System.Windows. Forms namespace).
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
"JT" <j...@onemain.c omwrote in message
news:a6******** *************** ***********@e6g 2000prf.googleg roups.com...
Hi,
I've realized that my good fortune of not having my computer go into
standby mode was the result of my application accessing a file on a
shared network drive. Not going into standby is a very good thing for
my application, but I don't want users to be required to share a drive
and file just to accomplish this.
I've read in old posts in various places stating that by importing
kernel32.dll I could access a function called
SetThreadExecut ionState(...) with a value of ES_SYSTEM_REQUI RED,
potentially ORed with ES_CONTINUOUS (or the equivalent DWORD values),
would accomplish what I need. I'm guessing this is not managed code
and would have to be marshalled in and used as unsafe code (please
forgive me for not knowing anything about marshalling or unmanaged
code).
Is there a managed code way to accomplish this? Does anyone have any
suggestions?
Thanks,
JT- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -


Feb 18 '08 #5
JT
Hey Willy,

I've given the user a preference setting to let him decide how he
wants the application to behave. I figure if he's set it so that it
will not go into full standby, then if he purposely places it in that
mode, he has a reason for it. The application doesn't crash if it's
in standby.

So what would a user do to cause standby mode when the application
setting has indicated otherwise?

JT

On Feb 18, 2:00*pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
Keep in mind that calling this API doesn't prevent a *user* to put the
system in Sleep state.

Willy.

"JT" <j...@onemain.c omwrote in message

news:94******** *************** ***********@d4g 2000prg.googleg roups.com...
Nicholas,

I just did my first P/Invoke and it works like a champ (on preliminary
evaluation)! *Are there any caveats about P/Invokes?

Thanks,

JT

On Feb 18, 12:07 pm, JT <j...@onemain.c omwrote:
Thanks Nicholas,
Before my first post I did a quick scan through WMI, and quickly got
lost, never having looked at it before, but I didn't see anything
relating to what I need. I will go look at your link and investigate
P/Invoke. I've never dealt with that either.
JT
On Feb 18, 11:48 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
JT,
You ^might^ be able to do this through the WMI provider for windows,
which means you would access the System.Manageme nt namespace, but to be
honest, doing it through the P/Invoke layer is ^not^ that big of a deal.
The declaration for the function is at:
>http://www.pinvoke.net/default.aspx/...ExecutionState.....
Also, you don't need unsafe code to call this. But a call through the
P/Invoke layer is required. In this case though, it's trivial. Some
sections of the .NET framework are completely reliant on the P/Invoke
layer
(pretty much everything in the System.Windows. Forms namespace).
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
"JT" <j...@onemain.c omwrote in message
>news:a6******* *************** ************@e6 g2000prf.google groups.com....
Hi,
I've realized that my good fortune of not having my computer go into
standby mode was the result of my application accessing a file on a
shared network drive. Not going into standby is a very good thing for
my application, but I don't want users to be required to share a drive
and file just to accomplish this.
I've read in old posts in various places stating that by importing
kernel32.dll I could access a function called
SetThreadExecut ionState(...) with a value of ES_SYSTEM_REQUI RED,
potentially ORed with ES_CONTINUOUS (or the equivalent DWORD values),
would accomplish what I need. I'm guessing this is not managed code
and would have to be marshalled in and used as unsafe code (please
forgive me for not knowing anything about marshalling or unmanaged
code).
Is there a managed code way to accomplish this? Does anyone have any
suggestions?
Thanks,
JT- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
Feb 18 '08 #6
"JT" <jt@onemain.com wrote in message
news:b5******** *************** ***********@i29 g2000prf.google groups.com...
Hey Willy,

I've given the user a preference setting to let him decide how he
wants the application to behave. I figure if he's set it so that it
will not go into full standby, then if he purposely places it in that
mode, he has a reason for it. The application doesn't crash if it's
in standby.
The API only prevents the system to go into standby mode or turn the monitor
off when triggered by the "power mode policy" settings. This doesn't prevent
the user from manually putting the system in standby mode.

So what would a user do to cause standby mode when the application
setting has indicated otherwise?

Start menu - Sleep or Press the Sleep or the Power button when configured
to put the system in Sleep state.

JT

On Feb 18, 2:00 pm, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
Keep in mind that calling this API doesn't prevent a *user* to put the
system in Sleep state.

Willy.

"JT" <j...@onemain.c omwrote in message

news:94******** *************** ***********@d4g 2000prg.googleg roups.com...
Nicholas,

I just did my first P/Invoke and it works like a champ (on preliminary
evaluation)! Are there any caveats about P/Invokes?

Thanks,

JT

On Feb 18, 12:07 pm, JT <j...@onemain.c omwrote:
Thanks Nicholas,
Before my first post I did a quick scan through WMI, and quickly got
lost, never having looked at it before, but I didn't see anything
relating to what I need. I will go look at your link and investigate
P/Invoke. I've never dealt with that either.
JT
On Feb 18, 11:48 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.caspershouse. comwrote:
JT,
You ^might^ be able to do this through the WMI provider for windows,
which means you would access the System.Manageme nt namespace, but to
be
honest, doing it through the P/Invoke layer is ^not^ that big of a
deal.
The declaration for the function is at:
>http://www.pinvoke.net/default.aspx/...ExecutionState....
Also, you don't need unsafe code to call this. But a call through the
P/Invoke layer is required. In this case though, it's trivial. Some
sections of the .NET framework are completely reliant on the P/Invoke
layer
(pretty much everything in the System.Windows. Forms namespace).
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard .caspershouse.c om
"JT" <j...@onemain.c omwrote in message
>news:a6******* *************** ************@e6 g2000prf.google groups.com...
Hi,
I've realized that my good fortune of not having my computer go into
standby mode was the result of my application accessing a file on a
shared network drive. Not going into standby is a very good thing
for
my application, but I don't want users to be required to share a
drive
and file just to accomplish this.
I've read in old posts in various places stating that by importing
kernel32.dll I could access a function called
SetThreadExecut ionState(...) with a value of ES_SYSTEM_REQUI RED,
potentially ORed with ES_CONTINUOUS (or the equivalent DWORD
values),
would accomplish what I need. I'm guessing this is not managed code
and would have to be marshalled in and used as unsafe code (please
forgive me for not knowing anything about marshalling or unmanaged
code).
Is there a managed code way to accomplish this? Does anyone have any
suggestions?
Thanks,
JT- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -


Feb 18 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3343
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96653/create_ps.htm#66206 Still i give the steps i followed. Preparing the Primary Database for Standby Database Creation
5
21582
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to a folder on mapped network drive (eg. N:\Storage that corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find part of path N:\".
1
4646
by: Z0gS | last post by:
I got this problem for the web application I try to access files on a remote server. string dirs = Directory.GetDirectories(@"E:\vehicles") E drive is a map to a network drive. I get the DirectoryNotFoundException. How do I solve the problem or the is another way to write the code Thank yo
3
13364
by: Bonj | last post by:
I need to write a windows service, and the only way it can access a shared drive on a file server on the network is if the installer is put in "User" mode - "LocalService", "LocalSystem" and "NetworkService" don't work. i.e. it can't access the shared drive. But in "User" it can. But I don't want it in user mode, if possible. I would rather it be a service. Is there any way to do it?
6
3048
by: Bijesh | last post by:
Hi All, I've developed a Windows Service that acts as a remoting server (.NET Remoting). The client(user) is able to connect to the server and start a program by giving the executable path of the program (in the server) along with the working directory and the arguments (parameters). This works fine if I try to start programs whose executable file is present witin the local drives of the server. If the application is in a netwok drive,...
3
3844
by: Tom Lant | last post by:
Hello everybody, I have been developing an application in Visual Basic.Net that queries an SQL database every 15 minutes. My problem arises when the computer upon which the application is running goes into standby mode. My application continues to run, but when the "15 minutes" timer fires, it cannot make the required connection to the database and the application crashes. What I really need is something to tell me the status of my...
0
2361
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with limited Success because there is a bug apparently in using IWshRuntimeLibrary. There must be some API calls to get this information since Windows Explorer seems to be able to get. Can anyone tell me what API's are used. I know GetLogicalDrivesA...
2
2865
by: Ian Murrell | last post by:
My application writes a text data file to a folder on another computer. The other computer is mapped by drive letter to the root (C) shared folder, eg as G:. The network is simple peer2peer, shared root folders etc. Immediately after restarting the application computer, and when my application attempts to write to the mapped network computer G:, VB returns a "network not accessible" error. This error will persist until I open...
1
1621
by: 4johnny | last post by:
I have a small office (in a workgroup environment not a domain) that has a number of DBs that reside on one XP PC and shared for everyone to use. All users have mapped drives to this share and when they tried to open a DB they got the message: "The file is located outside your intranet on an untrusted site. MS access will not open the file due to potential security problems." So I went into IE,intranet options, secutiy tab, and added...
0
9851
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10902
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10286
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9420
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5680
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4481
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.