|
i want to know how to get running application in windows xp through c# application, i thought that GINA.dll will help me but it didnt work
|
|
|
|
|
u must install dot net framwork in the xp windows installing component
|
|
|
|
|
amal_pro83 wrote:
how to get running application in windows xp through c# application, i thought that GINA.dll will help me but it didnt work
Where do you get that idea from? GINA is for user identification and authentication. That screen where NT/2000 said "Press Ctrl-Alt-Delete to logon" ... that's GINA...
Getting the Process list is easy. Look into "System.Process" class, here[^]. You'll need to import the System.Diagnostics namespace to use it.
RageInTheMachine9532
|
|
|
|
|
i got idea, from task manager u get from GINA got me , okay....i want to get opened applications..i know code of Process but i dont want all running exe on computer as most of them are services..i just want only applications running...breifly, all appear in taskbar as opened..got it
|
|
|
|
|
The Task Manager isn't part of GINA. But, it can be launched by it...
You'd have tp do some detective work to fish out the services from the applications. All a service is is a windowless application that runs in the background under a different user and desktop.
RageInTheMachine9532
|
|
|
|
|
thanks i did it
public static string[] Detect_Run_App()
{
int j=0;
Process[] processes=Process.GetProcesses();
for(int i=0; i
|
|
|
|
|
Told ya!
All it takes is a little research...
RageInTheMachine9532
|
|
|
|
|
Hi,
How to pass null to a ref bool or out bool parameter?
Thanks.
|
|
|
|
|
bool is a value type, therefore it cannot be null. bool is either true or false. There is no other state.
By the way, when using out , the variable must be assigned a value before the method returns. The value of your variable going in wouldn't matter because it will be assigned a value before you get it back. Passing null (even if you could) wouldn't have any affect.
Charlie
if(!curlies){ return; }
|
|
|
|
|
There is some sourceForge project available that does implement just that. Nullable Value types.
http://nullabletypes.sourceforge.net/
I wouldn't recommend it (if it's supposed to be a boolean, check for a boolean)
|
|
|
|
|
FYI .NET 1.2, set to be beta'd this year and released next year, will utilize 1.2 generics feature for a Nullable value type, defined as Nullable<T>. This would allow you to pass a null value into a value parameter. See here[^] for more info.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
It will be .NET 2.0, not 1.2. The file versions are only labeled as 1.2, just like the file versions for 1.1 are 1.1 but the assembly versions are still 1.0.5500.0. ".NET 2.0" is mentioned in many places on Microsoft et. al. sites.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Oh really? I didn't know that; I knew C# would be C# 2.0, but I was under the impression it was .NET 1.2.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
Here's one current reference: http://msdn.microsoft.com/vstudio/productinfo/roadmap.aspx#2005[^].
I believed they used ".NET 1.2" for a while but that started changing a few months ago.
[EDIT] Oh, and rightly so. A LOT (as I'm sure you know) is changing between 1.1 and 2.0, unlikes the few changes between 1.0 and 1.1. It's still mostly backward compatible, but it includes a lot of bug fixes, performance enhancements, control adapters (new way to provide owner-drawing that's truly aweseom!), many new ASP.NET enhancements including some for WSS/SPS, and - of course - generics.
[/EDIT]
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Try this:
void Foo(ref object boolean)
{
if (boolean == null)
else
{
bool value = (bool) boolean;
}
}
top secret
|
|
|
|
|
Hey all...ok, let me set things up...here is the prototype of the function i'm trying to use in an unmanaged dll within C#:
void myfunc(int a, int b, pvoid* output);
Ok, so the return here (output) will be a pointer to an array of pointers....within that array, each pointer is to point at the following structure:
struct MYSTRUCT{<br />
DWORD size,<br />
PWSTR aString,<br />
PWSTR anotherString<br />
} MYSTRUCT, *PMYSTRUCT;
I read on ms site that in order to handle the strings in the array, I need to define it as such:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]<br />
public struct MYSTRUCT<br />
{<br />
public uint size;<br />
public String aString;<br />
public String anotherString;<br />
public MYSTRUCT(uint size, String aString, String anotherString)<br />
{<br />
this.aString= aString;<br />
this.anotherString= anotherString;<br />
this.size= size;<br />
}<br />
}
Here is my imported function:
[DllImport("mydll.dll")]<br />
public static extern void myfunc(int a, int b, out MYSTRUCT[] output);
Now...this doesn't work, I don't even get returned the correct size of MYSTRUCT[]. I've tried quite a number of different variations as well. I've tried passing an array of IntPtr too, all to no avail. How does one deal with this? Do I need to get back the array of pointers and actually deal with the pointers themselves?
Jason
|
|
|
|
|
Here's[^] an excellent resource for understanding pointers and indirection through interop.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Cool, thanks...I got it figured out, it was a toughy. Here's how it's done:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]<br />
public classMYSTRUCT<br />
{<br />
public uint size;<br />
public String aString;<br />
public String anotherString;<br />
public MYSTRUCT()<br />
{<br />
this.aString= null;<br />
this.anotherString= null;<br />
this.size= 0;<br />
}<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class ArrayOfPtrs<br />
{<br />
public IntPtr ptr;<br />
public ArrayOfPtrs()<br />
{<br />
ptr = IntPtr.Zero;<br />
}<br />
}
And here is the call (allong with forming up the data after the call is made:
IntPtr outArray;<br />
BaseP2P.PeerGetNextItem(something, numItems, out outArray);<br />
<br />
MYSTRUCT[] pairs = new MYSTRUCT[numItems];<br />
ArrayOfPtrs ptrs;<br />
<br />
IntPtr current = outArray;<br />
IntPtr structure;<br />
<br />
for(int i=0; i < numItems; i++)<br />
{<br />
pairs[i] = new MYSTRUCT();<br />
ptrs = new WinP2P.BaseP2P.ArrayOfPtrs();<br />
<br />
Marshal.PtrToStructure(current, ptrs);<br />
structure = ptrs.ptr;<br />
Marshal.PtrToStructure(structure, pairs[i]);<br />
current = (IntPtr)((int)current + Marshal.SizeOf(ptrs));<br />
}
That works great. There should be a call to Marshal.DestroyStructure(...) made in there to clear up the unmanaged memory, but there is a function in the dll that clears this memory for me, so I do not use Marshal.DestroyStructure(...).
Jason
|
|
|
|
|
You should declare MYSTRUCT as a struct, not a class. Structs (value types) are allocated on the stack while classes (reference types) are allocated in the heap. When you pass this struct around, you don't want to keep a reference to it in most cases. As a struct (value type), it is passed by-value unless ref or out is used.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I think it has to be declared as a class because of me using:
Marshal.PtrToStructure(structure, pairs[i]);
If you declare it as a struct, you get the following exception:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: The structure must not be a value class.
|
|
|
|
|
I have 2 questions concerning a DataGrid. Basically, I have a DataTable with 8 DataColumns. The table is initially empty, and the user fills in the information at run-time. Here are my questions:
1) I don't want every column being the same width at startup. How can I programatically change the column widths directly after I set the DataSource?
2) Each time a new row is created in my table, all of the cells contain "(null)". I want the cells to just be initially empty. How is this done?
These will probably be 2 very easy questions to answer. I appreciate the help! 
|
|
|
|
|
i cant answer the first one!
u cant make empty variables! when u create them and do not assign them a value they are null. u can try assinging them an empty string like
code>string empty = "";<
|
|
|
|
|
Assigning empty strings worked just fine. Thank you for your post! 
|
|
|
|
|
The answer to both questions is to apply a DataGridTableStyle .
DataGridTableStyle style = new DataGridTableStyle();
style.MappingName = "MyTableName";
DataGridColumnStyle colStyle = new DataGridTextBoxColumn();
colStyle.Width = 85;
colStyle.NullText = "";
colStyle.MappingName = "Column1";
colStyle.HeaderText = "First Name";
style.GridColumnStyles.Add(colStyle);
dataGrid1.TableStyles.Add(style);
Charlie
if(!curlies){ return; }
|
|
|
|
|
As an answer to your first question: you can add DataGridStyles to your Grid, in the designer and in code. Do this before you point the Grid to its datasource. If you program the available columns manually, you can set their Width and headertext too. All columns you want invisible, set the respective widths to 0.
You can also define a methodthat returns a DataGridStyle and add that to the Grids style, possibly deleting the old style (DataSource has to be null to do that I believe)
|
|
|
|