|
Hi,
I have a windows service in C# (.NET framework 1.1) running on Windows XP
PRO SP2. This service essentiallt starts a printjob watcher. Please see the code
snippet below.
queryInterval = ((SchedulerData)obj).Interval/1000;
//queryInterval=1;
this.printEventWatcher = new System.Management.ManagementEventWatcher();
this.printEventWatcher.Query = new System.Management.EventQuery("SELECT *
FROM __InstanceCreationEvent WITHIN "+queryInterval+" WHERE TargetInstance
ISA \"Win32_PrintJob\"");
string hostName = Dns.GetHostName();
this.printEventWatcher.Scope = new
System.Management.ManagementScope("\\\\"+hostName+"\\root\\CIMV2");
printEventWatcher.EventArrived+=new EventArrivedEventHandler(this.Arrived);
printEventWatcher.Start();
This service fires the EventArrived event when running as my login account.
i.e When the service is run as MaxBici and I login as MaxBici and print
documents, I see the events being fired.
But, when the service is run as NT AUTHORITY\SYSTEM (Local System account),
and I login as MaxBici and print documents the EventArrived event is not
fired.
The query interval was set to 1 second in both the above cases.
Could anyone help me with this?
What does the scope in the event watcher signify?
Isn't the data in the WMI tables visible to all users in a PC?
Thanks in advance.
Max
|
|
|
|
|
could u tell me about Integrated Security=SSPI, what is the role in database connection
|
|
|
|
|
|
|
hi guys, could you tell me how i can add uninstallation way to the setup project, i want to able the users of my project to uninstall it from the program menu not from add remove programs from the control panel ... how i can add it to my setup project ... thanks alot
Thanks alot
Hamody
|
|
|
|
|
Is it possible to open a printer directly connected to the "Lpt:" port on a Windows XP system? I have a form that must be set up exactly on an old dot-matrix printer, and then printed after filling in some values. I would like to open the printer and send ASCII characters to the device.
Is this possible???
Thanks
XamIam
max@maxpcsupport.com
|
|
|
|
|
Hi.
---------
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = @"C:\file.txt";
p.StartInfo.FileName = "print ";
p.StartInfo.CreateNoWindow = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Serdar YILMAZ
Senior Developer
|
|
|
|
|
Thanks Serdar,
This looks like the file is printed through the spooler. Is this the best I'll be able to do with Windows XP? Write to a file and print via the spooler.
Thanks again for your help,
--max
XamIam
max@maxpcsupport.com
|
|
|
|
|
Dear friend, need a help
I have a mdi form and i want to open child form into tabcontrol so i can use that form simutenously by clicking on tab pages.
if its possible please help me soon
thnx
|
|
|
|
|
Can anyone tell me through code in C#,i have drawn roads in form of spline curves using paint brush,now i want to load this bitmap image in C# windows application and then
by reading the pixels of each line in bitmap image to store the piece wise spline curves equations in linked list,as a copy and erasing all the lines after storing these lines in linked list,so that if i click near the line in bitmap image ,that particular line will display .
I will be very thankfull to you.
|
|
|
|
|
Anyone know how to reboot the pc that the application is running on using code?
Cheers
Kev
|
|
|
|
|
|
That should do the trick:
clickedy
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
That's great, i can get the pc to log the user off no problems but im still having problems rebooting it. I know why, i dont know how to set the privileges for the current process.
The calling process must have the SE_SHUTDOWN_NAME privilege
I'm reading through the MSDN docs trying to figure it out but the only one i've found so far is written using C++ code, and the classes are not the same in C#. If you could help me set the privileges that would be great!
Cheers
Kev
|
|
|
|
|
I'd suggest you taking a look at www.pinvoke.net and convert the appropriate API calls by yourself.
This should help you a bit.
I've not done this in C# myself yet.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Got it sorted now, thanks.
Found an article that had already converted the API calls to C# and used them.
Cheers
Kev
|
|
|
|
|
HI,
can you give me the code of Rebooting
regards
sanjeev
email: sanjeevsinghh@gmail.com
|
|
|
|
|
Here's some code for converting the functions you need to reboot with.
[DllImport("user32.dll")]
private static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[StructLayout(LayoutKind.Sequential, Pack=1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
[DllImport("kernel32.dll", ExactSpelling=true) ]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]
internal static extern bool OpenProcessToken( IntPtr h, int acc, ref IntPtr phtok );
[DllImport("advapi32.dll", SetLastError=true) ]
internal static extern bool LookupPrivilegeValue( string host, string name, ref long pluid );
[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]
internal static extern bool AdjustTokenPrivileges( IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen );
Then you just need to call ExitWindowsEx, see above for links tyo the MSDN documentation for it.
Kev
|
|
|
|
|
Look at the win API function ExitWindowEx.
/\ |_ E X E GG
|
|
|
|
|
I have a console utility I'd like to interact with and get it's output.
I can send in a list of commands into it via < like this:
myapp < commmands.txt
also I can do:
myapp "command1 asdf" "command2 asdf" "command3 asdf 223"
and so on..
What feature would I use to send commands into it and what would I use to read it's output ?
thanks,
H
|
|
|
|
|
|
Let's say I'm interacting with the utility "dir"
i'd like to do as my command:
"dir " + strMyDir
and then read the output from this command and parse it to my likeing
|
|
|
|
|
|
Yes, thanks.
|
|
|
|
|
Hi,
When I call InternetDial function from WinInet.dll I don’t want from system to show me modal dialog box with values from default internet connection. For example when I uncheck all the option in Dialing options in properties of my default dial-up connection and double click on my default dial-up connection I haven’t seen any modal dialog box. Computer starts to call other site immediately.
From my program I want to produce same behavior as mention before.
Thanks,
|
|
|
|