|
Use StructLayoutAttribute and for poinetrs in the structre use IntPtr trype. You can look into MSDN for more info and example.
Mazy
You're face to face,
With the man who sold the world - David Bowie
|
|
|
|
|
A string is a character array, and the address of a string is the address of the first character. SAme with other arrays. For those params, it's no problem for the default marshalers to handle this. Just be sure to use the StructLayoutAttribute with CharSet.Auto and UnmanagedType.LPTStr with the MarshalAsAttribute .
As far as marshaling the pointers, you'll have to pin them so that the GC doesn't move them (or garbage collect them, although that shouldn't happen until they're out of scope) while the unmanaged code is processing. For information on that, see the fixed keyword in the .NET Framework SDK, under the C# language specification section (or just type "fixed Statement" in the help index).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can anyone tell me how to read a File Property like the Title, Subject, Author...
System.IO.File can only read those simple File properties like File Size, Creation date...
I have tried using "Interop.DSOleFile.dll", it works...but It is not Strong Named....
I want something strong named that can read the File Property...
Thank You!!
|
|
|
|
|
You can make that interop assembly strong named. If you use VS.NET to import a COM typelib, before creating it right-click on your project, select Properties, and set your "Wrapper Assembly Key Name" or "Wrapper Assembly Key File" under the "Common Properties/General" section. If using tlbimp.exe from the .NET Framework SDK, you can use the /keyfile:FileName or /keycontainer:KeyName command-line switches.
To answer your first question, though - no. The .NET base class library does not support these additional streams. You have to either rely on interop'ing a COM library (like you've done) or P/Invoking all the necessary functions and defining the proper structures and consts (etc.).
There is a .NET library someone made and documented here on CodeProject that works pretty good. See the article, Accessing alternative data-streams of files on an NTFS volume[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello everybody
After alot of sleepless nights, I have finally finish my newest website dedicated to serve C# programmers with a C# Resource Windows, I hope everyone will enjoy using it and I hope the moderator don't treat this post as a spam ^_^;;
http://www.csharpusa.com or http://www.csharpgames.net
This isn't really a website since it would only work on Microsoft Windows with Internet Explorer 6, sorry to the Linux folks X_x;
I was formerly known as the C#n00b on this forum and I asked stupid questions because I'm a newest n00b to C#, I would like to give everybody a funny joke.
One day, C#n00b wanna study programming so he asked an old wise programmer to teach him, the old wise programmer said:"just open visual studio .net and create a new windows application and press F5", so C#n00b follow the direction and did what the old wise man said, then he realize there's a window popped up, the old wise guy said:"see? you just made your first windows application", C#n00b is so happy and excited and said:"omg, I made a software, I'm now a programmer, hahahahaha".
the end, not funny? oh well, I thought it was kinda funny.
C# Resource Windows
http://www.csharpusa.com
http://www.csharpgames.net
Super Robot Wars English Game Project
http://www.shintasoft.com
|
|
|
|
|
Wierd sence of humor you have say's Yoda
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
i cannot for the life of me figure out how to get this to return a string that is not formatted in scientific notation
is there a simple guide or set of examples somewhere on how to use IFormatProvider?
msdn doesn't seem to provide any examples
edit: i found an example, it uses a mask... but why does the msdn page mention special characters (d/c/etc) for formating?
where can i find a reference for the available masks?
|
|
|
|
|
This is a link to really good site on how to format numbers:
http://authors.aspalliance.com/aspxtreme/aspnet/types/numericformatstrings.aspx
|
|
|
|
|
You keep reading the wrong things. Did you try reading the documentation for the NumberFormatInfo , which implements IFormatProvider ? You don't even need to specify this for numeric types in string.Format (or any other formatting method like Console.WriteLine ). There's also a big section on formatting in the .NET Framework SDK, which should be your first stop for .NET-related documentation, articles, and examples.
There is a simple solution for the scientific notation:
string s = string.Format("{0:e}", myNum);
s = myNum.ToString("e");
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
If anyone like to contribute to thsi site, please contact us.
|
|
|
|
|
is there any way faster then
using split()?
the lines are all the exact same format, with no nulls, etc
this is what i am using:
while (html_sr.Peek() >=0)
{
txt_file = html_sr.ReadLine();
user_info = txt_file.Split('\t');
SQLAction.InsertUpdateUser(int.Parse(user_info[5]),user_info[2],int.Parse(user_info[4]),double.Parse(user_info[3]),date_modified,int.Parse(user_info[1]),int.Parse(user_info[0]));
}
|
|
|
|
|
The first obviouse thing is:
while (html_sr.Peek() >=0)
{
txt_file = html_sr.ReadLine();
Why not use:
while((txt_file = html_sr.ReadLine()) != null)
{
}
Now, you no longer have to perform the peek operation and your test is against a value you would get anyway. (Since the RealLine method already performs some operation to determine whether it is at the EOF why duplicate the effort)
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"Get in touch with your Inner Capitalist - I wish you much success!" -- Christopher Duncan, Lounge 9-Feb-2004
|
|
|
|
|
Thanks!
i had thought that Readline would throw an exception
now to test and see if this will provide any performance improvement
though i suppose most of my problem is the SQL method...
right now it proceses on average 170 of those lines per second, just trying to squash it down as much as possible
|
|
|
|
|
You should probably use some profiler to see what takes most time.
It probably is sql query. Make sure you're not opening the connection with each query, but open it once and do all the queries then.
|
|
|
|
|
thanks...
the query is actually a single stored procedure, but a complex one
|
|
|
|
|
If you're doing INSERTs on a SQL Server from a comma-delimited file, use BCP (Bulk Copy).
It can do up to 100,000 lines/second on a big machine and on desktop machines it processes up to 10,000 lines/second.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
unfortunatly the text file needs to be "processed"
|
|
|
|
|
Hi there
How can i restrict the appearance of child forms?
i only want 1 instance of a particular child form
how do i do that?
VisionTec
|
|
|
|
|
visiontec wrote:
How can i restrict the appearance of child forms?
This is ambiguous. Appearance in this context could mean the number of times it appears or the way it looks.
visiontec wrote:
i only want 1 instance of a particular child form
how do i do that?
Apply the singleton pattern to it. Actually, I'm not too sure whether that is completely wise or not in the context of a form. If your not already aware, a "singleton" is a class that only ever has one instance in existance at any time (some more strickter definitions might even say only one instance ever). This is acomplished by making the constructor private, creating static field of the class type and creating a static method that creates the one and only instance or returns the existing instance. If you need to know more about singletons just ask and I, or someone else, will help you out.
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"Get in touch with your Inner Capitalist - I wish you much success!" -- Christopher Duncan, Lounge 9-Feb-2004
|
|
|
|
|
Hi there
In my mdi app i have a child form which has a tabcontrol on it.
there r 2 pages in that tabcontrol
Now how can i load the child form to show
the start page that i want?
VisionTec
|
|
|
|
|
You could pass an int to the child form's constructor, and in the constructor set TabControl.SelectedIndex to that int , or do this using the set accessor of a property of your child form, or many other ways. This is a simple object-oriented design (heck, even procedural designs would be simple).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I am very familiar with DCOM and its inner-workings, but this is my first attempt at doing something with C#.
I want to write a windows service in C# that a ASP.NET webapp or C# application can talk to as a client. The client would have to pass several pieces of information to the service and exit. The service will add the request into a queue and then process it as its leisure. The service will post the results of the request to a ftp site for user's to download. So there is nothing syncronous about this operation. The client does not wait around for the results.
Should I be using .NET remoting to talk to the windows service? If so, should the remoted object be a singleton or a single call? Should the service implement its own queue/thread mechanism, or use the built-in thread-pooling to handle the request queue?
Any ideas/suggestions would be helpful.
Thanks in advance,
Kevin
|
|
|
|
|
Kevin Tambascio wrote:
Should I be using .NET remoting to talk to the windows service?
Yup. It's really straight forward to set up what you want to do.
Kevin Tambascio wrote:
If so, should the remoted object be a singleton or a single call?
I prefer the singleton mode because I can make multiple calls on the same instance rather than a new instance.
Kevin Tambascio wrote:
Should the service implement its own queue/thread mechanism, or use the built-in thread-pooling to handle the request queue?
As for this, read my article on .NET's built in threadpooling. http://www.codeproject.com/csharp/threadtests.asp[^] It's intended to service threads that are mostly asleep and do their thing quickly. I'd probably suggest Stephan Stoub's thread pool manager, which you can download from the article.
Hope that helps!
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Marc,
Thanks for your help, I hope you won't mind a few more questions.
I got .NET remoting to work between two .exe's, seems very nice so far. If I create the remote object as a singleton (using multiple clients), will functions in that remote object be called from one thread in some order, or just called all at once? Do I have to synchronize those calls to shared objects?
Also, this service will eventually be called from a web app (ASP.NET) instead of a exe. Will each user's instance of the website be able to create a TcpChannel at the same port number to talk to the remote object, or will each of the client's have to have some knowledge of each other to find a unused port number to create that TcpChannel?
Thanks again,
Kevin
|
|
|
|