|
How can I know the size an object in memory?
Anyone?
vSoares
|
|
|
|
|
You can use sizeof or Marshal.SizeOf. However, that doesn't take into account the memory used by the garbage collector to track the object.
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.
|
|
|
|
|
How can i close an application using C#? I have tried using the Process.Kill method and it works pretty well, but does this method force the application to close or does it tell it to close. For example, i have noticed that many applications save a lot of thier settings while closing but when i use the Process.Kill method, they just seem to close forcefully. How do I go around this?
|
|
|
|
|
|
hi guys,
how can i write data/information from the database server to a file stored in the client PCs of my network. can i do it at the same time? if not its ok, as long as i can send all the data to all my client PCs.
the data is not that big, about 20-30 lines of text.(3-5 words per line) it just contains a list of information to be used by my Client side program... tnx..
|
|
|
|
|
Hi there,
I would like to use a progress bar in my application. What i am looking for is a wakeup bar that goes from 0 to 100 and back to 0 again. I would like run it when the process is running so that user know that process is running. Appreciate any feedback.
JS
-- modified at 10:20 Monday 16th January, 2006
|
|
|
|
|
You can use:
progressBar1.PerformLayout();
Or
Application.DoEvents()
SINCERELY ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
Thanks Anthony,
Application.DoEvents() is what I was looking for. It did the trick.
Thanks again.
JS
|
|
|
|
|
Hi,
Is it possible to tell the Visual Studio 2003 to not print the "The thread '<no name="">' (0x11c4) has exited with code 0 (0x0)." messages in the output window? And if yes, how?
Thanks
Roland
Hi! I'm a signature virus. Copy me into your sig file and help me spread!
Follow your Euro notes in their tracks
|
|
|
|
|
Hi
Does anyone know what TypeConverter to use to open a OpenFileDialog from the propertygrid?
Thank you,
D
|
|
|
|
|
Hi D
this is the code:
[Browsable(true), Description("The filename for destination.")]
[EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string FileName
{
get {return _FileName;}
set {_FileName = Path.GetFileName(value);}
}
|
|
|
|
|
|
you can also create your own editor class.
1. create a new class and implement the openfiledialogeditor.
override the initialize methode (this methode have 1 parameter e.g. the
openfiledialog) now, in the methode you can set your own properties e.g title, filter ....
2. change the editorattribute in the property to your class
[Browsable(true), Description("The filename for the destination.")]
[EditorAttribute(typeof(MyNamespace.MyFileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string FileName
{
get {return _FileName;}
set {_FileName = Path.GetFileName(value);}
}
|
|
|
|
|
Is there anyway of creating a graphics object without using the following methods
1) Graphics g=e.Graphics;
2) Graphics g=this.CreateGraphics;
i an asking this because i want to create a graphics object in my own userdefined function
|
|
|
|
|
What is it that you are trying to do? What is the purpose for using a Graphics object? Answering these questions would give us a better idea of how to help you.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
There are several static functions on the Graphics class. Which one to use depends on what you try to achieve.
Example:
Bitmap b = new Bitmap(100, 100);
using (Graphics g = Graphics.FromImage(b)){
g.FillRectangle(Brushes.Red, 10, 10, 20, 20);
}
|
|
|
|
|
Hi.
I have struct in C++:
struct MY_STRUCT
{
int x;
int y;
char** arrNames; //array of strings
}
I have function GetMyStruct, which gives me pointer to this struct, but
I can't get the array of strings (MY_STRUCT.arrNames).
MY_STRUCT* GetMyStruct();
In C# :
public struct MY_STRUCT
{
public int x;
public int y;
public string[] arrNames; //array of strings
}
public class MyWrapper
{
[DllImport("MyDll.dll")]
private static extern IntPtr GetMyStruct();
public static MY_STRUCT GetMyStructW()
{
IntPtr p = GetMyStruct();
return (MY_STRUCT) Marshal.PtrToStructure(p, typeof(MY_STRUCT));
}
}
BUT MyWrapper.GetMyStructW() doesn't work. Plllease help.
jurot
|
|
|
|
|
Try changing your c# struct to the following:
public struct MY_STRUCT<br />
{<br />
public int x;<br />
public int y;<br />
public System.IntPtr arrNames;<br />
}<br />
<br />
Your calling code looks like this:<br />
<br />
public class MyWrapper<br />
{<br />
[DllImport("MyDll.dll")]<br />
private static extern IntPtr GetMyStruct();<br />
<br />
public static MY_STRUCT GetMyStructW()<br />
{<br />
IntPtr p = GetMyStruct();<br />
IntPtr pArray;<br />
IntPtr pString;<br />
string[] strings;<br />
MY_STRUCT s;<br />
<br />
s = (MY_STRUCT)Marshal.PtrToStructure(p, typeof(MY_STRUCT));<br />
<br />
pArray = s.arrayNames;<br />
<br />
<br />
pString = Marshal.ReadIntPtr(pArray);<br />
<br />
while( pString != null )<br />
{<br />
strings[i] = Marshal.PtrToStringUni(pString);<br />
i++;<br />
pString = Marshal.ReadIntPtr(pArray);<br />
}<br />
<br />
return ( s );<br />
<br />
<br />
}<br />
}
I hope this helps.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Thanks. Finally it works
jurot
|
|
|
|
|
Hi once more,
I found out, that it works fine only if I have MY_STRUCT.arrNames 1 string!
When I have more than one, all strings in the result array are the same.
I guess the cycle
while( pString != null )
{
strings[i] = Marshal.PtrToStringUni(pString);
i++;
pString = Marshal.ReadIntPtr(pArray);
}
in Marshal.PtrToStringUni(pString) is reading still the same value MY_STRUCT.arrNames[0].
jurot
|
|
|
|
|
Try this:
while( pString != null )
{
int byteCount;
strings[i] = Marshal.PtrToStringUni( pString );
i++;
byteCount = System.Text.Encoding.UnicodeEncoding.GetByteCount(strings[i]));
pString = Marshal.ReadIntPtr( pArray, byteCount );
}
I hope this helps.
Andy
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
How do I format a string so that it is displayed in a grid with mixed fonts.,just like that!
Thanx.
-- modified at 9:21 Monday 16th January, 2006
|
|
|
|
|
There is no built-in way for this. You will have to create your own custom DataGridColumnStyle and implement it yourself
|
|
|
|
|
At least I know where to go next! Thanx.
|
|
|
|
|
Hi there,
I need some help of changing extensions of files..
My code so far is:
<br />
string filename = Path.Combine(@"C:\Test.txt", @"C:\Test.txt");<br />
filename = Path.ChangeExtension(filename, "old");<br />
the filename variable does equal C:\Test.old but it never actual changes the extension in windows "explorer"...
i tried so many different ways but always get stuck with this problem..
Please help thanks
Best regards
|
|
|
|