|
how do i get the filename of a process?I know how to get the list of processes on a local machine, but i'd like to know how to get the full path (i.e: c:\windows\system32\svchost.exe) of a process.
|
|
|
|
|
you can use the Process.GetProcessesByName or Process.GetProcesses to get a Process object. You can then use the MainModule property to get a ProcessModule object for the process, and the ProcessModule has a FileName property that gives a full path to the processes .exe (etc.)
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
|
no problem.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Hi,
I am sending a file between a client and server I made and I am not sure how to detect when the file is complete. The only way I can think of is sending the size of the file to start and then continously checking to see if it has reached that size on the other end.
There must be an easier way...
If anyone could help me out a bit that would be awesome.
Thanks very much,
Steve
|
|
|
|
|
I would think that would be the best way to do it. After all, that must be what IE does when it shows you how much you've downloaded so far and how much you have left to download. Besides, then you could show some nice little progress bar.
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
LostInACave wrote:
There must be an easier way...
I think you could implement this type of idea..... this is not tested, just the deal.
FileStream fs = new FileStream("Test.txt", FileMode.Open);
long BytesRemaining = fs.Length();
while(BytesRemaining)
{
fs.Read(buff, offset, count);
long BytesRead = buff.Length()
BytesRemaining -= BytesRead;
}
This way your while loop will exit only when you have transfered all the data.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Do you guys know of any telnet components that are commercially available? I would love to write my own (or use one here on CP), but Dad/Boss thinks going with a prepackaged solution is better. Please don't suggest IP*Works from /n software. I hate their package.
Thanks.
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
Im no expert [make a comment and ill track you down and castrate you!] but isnt telnet simply the transmition of raw data? in which case - you could whip one up and pretend it was a prepackaged one
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
real not fake? if Word has a 'real' fullscreen, what is a fake one?
Try setting borderstyle to none and setting the width and height to the primary display size, and move the form to the top left of the primary display.
|
|
|
|
|
Won't work - it'll duck behing the task bar. You have to override the CreateParams property to return base.CreateParams OR'd with the values for WS_POPUP and WS_EX_TOPMOST , using the screen's physical size for the size of the form. SystemInformation does not provide this (only the working area, which is the area that any task bars don't use) so you'll have to P/Invoke GetDeviceCaps using HORZSIZE and VERTSIZE as parameters (two separate calls) passing an IntPtr you get from Graphics.GetHdc() (make sure to call Graphics.ReleaseHdc() right away after you're done with the HDC).
You can also use ChangeDisplaySettings() (or ChangeDisplaySettingsEx() ) to accomplish the same thing, but it's a tad-bit more complicated.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
What about PrimaryScreen.Bounds? Is that not the full screen size? ( i would test it but i've got systems issues at the moment!)
|
|
|
|
|
Well, perhaps I expressed myself in a stupid way I mean real as the one found in games and word -> no taskbars no menus or other apps (TOPMOST) should pop-up infront of the window.
|
|
|
|
|
|
I have a .NET Winform served up by a IIS server. I'm also accessing .NET Web services. When referencing the .NET Web services, the paths are hard coded. I need to setup a relative path for application deployment purposes. Can anyone help?
Thanks,
Shane
Shane L. Hatcher
|
|
|
|
|
The WinForm doesn't really know where it's running from, but there are solutions. First, it'd be nice if you could use the Value of the Url evidence presented to your AppDomain, but when a control is hosted in IE, this is always *just* the same name (MSDN Support claimed that was intentional...whatever). What you could do, however, is some of the following things:
1. Use AppDomain.CurrentDomain.BaseDirectory to get where the WinForm is running; however, this is not always correct (circumstantial, but usually correct).
2. Add a public property to your form as a string (the URL to the Web Service) and use a <param /> tag using the property name as the name and the value as the URL. Then, bind to the Web Service dynamically.
3. Specify this in your <appSettings /> section of your form's client .config file (make sure to change the handler from *.config to Web.config in your machine.config file, otherwise your form can't access its own configuration file!).
These are just a few ideas. #1 is probably the best (although prepare that - for some rare reason - the APPBASE is wrong) if you always want them to have the same relative path, but #2 and #3 allow your clients to specify different paths (perhaps even on different servers) to suite their needs.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Is there a way to get a raised Panel, the Border style property allows only FixedSingle, Fixed3D or None and Fixed3D only produces a sunken panel.
There is another border property Border3DStyle which allows things like SunkenInner, Raised, RaisedInner,RaisedOuter, Sunken, SunkenInner, SunkenOuter but that is for the Panel parent class.
If I could view/modify this property for a panel it would be great.
A C# example would be great. I will be creating a panel on the fly in my code.
Cheers in advance
|
|
|
|
|
I cant help you in c# but the ControlPaint class has what your looking for:-
ControlPaint.DrawBorder(_FormAreaG, Me.DisplayRectangle, Color.FromKnownColor(KnownColor.ControlLight), ButtonBorderStyle.Outset)
You have to redraw this in the paint event.
|
|
|
|
|
Change "Me" to "this" and it'll work in C#. Remember, the .NET framework provides the same class library for every language - it's only a matter of syntax.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Thanks to all, I have tried 2 slightly different calls based on the original code which do give different results but both work well.
ControlPaint.DrawBorder( pe.Graphics, this.DisplayRectangle, Color.FromKnownColor(KnownColor.ControlLight), mButtonBorderStyle);
ControlPaint.DrawBorder3D( pe.Graphics, this.ClipRectangle, mBorder3D);
|
|
|
|
|
I'm having a problem showing my context menu. One of the options is delete,
which deletes a control of a form. The menu is displayed with :-
PopMenu.Show(Me, Me.PointToClient(New Point(MousePosition.X,
MousePosition.Y)))
But after I've deleted a control I get this wierd error message:-
ContextMenu cannot be shown on an invisible control.
The control is obviously still visible so why does it do this?
|
|
|
|
|
I don't know how your PopMenu is initialized and attached but what I know is that .NET context menus are automatically shown on right-clicks, and they have to be preably attached to the control with the .ContextMenu property. You never call Show(), or you expose yourself to such things.
Using Show() directly is a hack. The executed code is as follows :
public void Show(Control control, Point pos) {
object[] local0;
if (control == null) {
local0 = new Object[2];
local0[0] = "control";
local0[1] = "null";
throw new ArgumentException(SR.GetString("InvalidArgument", local0));
}
if (!(control.IsHandleCreated) || !(control.Visible))
throw new ArgumentException(SR.GetString("ContextMenuInvalidParent"), "control");
this.sourceControl = control;
this.OnPopup(EventArgs.Empty);
pos = control.PointToScreen(pos);
SafeNativeMethods.TrackPopupMenuEx(this.Handle, 64, pos.X, pos.Y, control.Handle, null);
}
Make sure the associated control .Visible property is set to true. When the code reaches TrackPopupMenuEx, it relies on standard WIN32 menus, and at this point you are sure the context menu displays well.
|
|
|
|
|
Thanks Rod,
The problem I've found out is to do with my subclassing, even using the method you suggested it bombs, but I have now found out that it's a windows message thats bombing it thanks to your advice
|
|
|
|
|
It's WM_CONTEXTMENU that is causing the app to bomb.
When the message is passed down the chain (MyBase.WndProc(message)) it bombs with the not visible error.
I can't find TrackPopupMenuEx in the net framework, do you know where I'd find it?
|
|
|
|
|
LeeDaviesVBSource wrote:
I can't find TrackPopupMenuEx in the net framework, do you know where I'd find it?
That's not TrackPopupMenuEx(...), that's SafeNativeMethods.TrackPopupMenuEx(...), where SafeNativeMethods is a namespace of WIN32 imported functions defined like this :
[DllImport("user32.dll")]
public extern static bool TrackPopupMenuEx(IntPtr hmenu,
int fuFlags,
int x, int y,
IntPtr hwnd,
TPMPARAMS tpm);
which at run-time is interoped to a native WIN32 ::TrackPopupMenuEx(HMENU hmenu, UINT fuFlags, int x, int y, HWND hWnd, LPTPMPARAMS tpm) call.
This method call is proven. What could be wrong at this point is the hmenu (invalid or NULL), or a NULL owning window handle (hWnd). The last parameter can be NULL.
|
|
|
|