|
Microsoft wrote:
Although many of the filters provided with DirectShow support property pages, they are intended for debugging purposes, and are not recommended for application use. In most cases the equivalent functionality is provided through a custom interface on the filter. An application should control these filters programatically, rather than expose their property pages to users
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/introductiontodirectshow.asp
Does anyone know how to "control these filters programatically"? Or where can I find a sample or documentation on the topic?
Very appreciate for any kind of help. Thanks.
|
|
|
|
|
|
Welcome to the world of COM interop in .NET. You must declare the interfaces in managed code, using the same GUIDs (IIDs for interfaces, CLSIDs for classes) in the GuidAttribute , define the methods in the same order and/or with the same DISPIDs (using the DispIdAttribute ),etc.
You must also P/Invoke APIs like OleCreatePropertyFrame that the same you linked (in the other post) uses.
Before just jumping into it, you really must read the .NET Framework SDK documentation covering these topics. Read Interoperating with Unmanaged Code[^] and the class documentation[^] for the System.Runtime.InteropServices namespace. For example, the Marshal class has static methods that can be very helpful in marshaling structs, alloc'ing and freeing memory, and more.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi,
How to Prevent decompile or dis-assembly c# project (.NET)?
its possible prevent to decompile .net assembly?
thanks.
|
|
|
|
|
No, but you can use an obfuscator to make it very difficult to comprehend. You can also use ngen to compile it to native code which adds another layer of difficulty.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Note however that you shouldn't ngen it before deploying. ngen.exe should only be run on the assemblies during or after deployment. This is only meant to boost performance by pre-JIT compiling the IL, not as obfuscation.
Yes, as Colin said, it can help your "cause" but it can also lead to problems since JIT compiling an assembly compiles the IL to native code, which may be a little different from machine to machine and may reduce portability.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
I created a basic C# Windows application, built it and executed the resultant executable and looked in task manager to find that it was using 7,848K of memory. Does anyone know how this can be optimized so it uses much less memory? Maybe I'm missing something very basic here, but I wasn't able to find a solution anywhere I looked.
Am I expecting too much? I'd guess and say it should only be using 100K. It is after all an empty form.
Thanks,
Ray
_____________________________
You're not an inker, you're a tracer!
|
|
|
|
|
8,000K isnt all that much... what version of windows do you have? and whats your comp's RAM?
|
|
|
|
|
I have winXP and 512MB ram running @ 2ghz. However, none of that is relevant. And I completely disagree with you that a one form executable with no controls on it should be using 8MB or RAM.
I compiled the same type of project using Managed C++ and had the same result for mamory usage. however if you run notepad.exe or calc.exe you will see they both use between 1.4 and 1.9 MB each and they both have controls as well as a decent amount of code behind them.
I don't want to start an argument of whether or not an exe would scale at the rate of 8MB per form loaded into memory, but I would like to know if someone know of a way to optimize the memory usage.
Thanks,
Ray
insurgentpyro,
Not worrying about memory consumption is very lazy programming at best. How has growing up as a VB only programmer been? Open your mind, code should be written well and made to be as efficient as possible. Don't use the expense of todays hardware as an excuse.
_____________________________
You're not an inker, you're a tracer!
|
|
|
|
|
I agree with you about your app eating up too much memory, however there is little you can do about it initially. See, when your C++ app starts up there is no run-time enviornment or virtual machine needed to be loaded because your C++ app is a native app in the windows world. When you start up your .NET app parts of the .NET framework needs to be loaded also because .NET is not yet 100% fully part of the OS. In future version of Windows (Longhorn and on) .NET will be native part of the OS so you will not have overhead like this. In the meanwhile it is true that your .NET app will eat up 20MB of RAM because of the virtual machine and the other various framework components (like winforms, exception management mechanism, etc...) but over time unused RAM will be garbage collected. I wrote a trading application's front-end using C# and upon startup it ate up 30~40MB of RAM but as it was running throughout the day it actually went down after a couple of garbage collection cycles.
|
|
|
|
|
You assuming that the program is a little .EXE with just a single form and no other controls. Since it's a MANAGED application, it has the MANAGING RUNTIME and a base class library behind it, called the .NET Framework. This is where all that memory is being used.
Can you reduce it's footprint? No...
If the memory footprint is a problem, you'll have to write your app in non-managed C++. You'll loose the ease of use of C# and the .NET Framework Base Class Library.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This is a Runtime application. The Common Language Runtime (CLR) is loaded, along with the base class libraries (BCL assemblies) and any third-party assemblies when the Type they define is needed. This can consume quite a bit of memory. The same is true for Java applications and anything that uses a runtime in this manner (C/C++ has a runtime, too, but since it compiles to native code where .NET and Java compile to bytecode, that runtime is just common functions).
There are things you can do to help eliminate waste, though. For example, when you show a modal form (when you call Form.ShowDialog ), make sure you call Dispose on the forum afterware to clean-up native resources. Native resources aren't managed by the Runtime GC (Garbage Collector), so they must be freed by calling Dispose (and there's a lot of discussion about finalizers and Dispose on the 'net you can google for).
A good way to make sure a form is always disposed is using the using block statement:
using (PromptForm form = new PromptForm())
{
DialogResult result = form.ShowDialog();
if (result == DialogResult.OK)
return form.Answer;
else return null;
} PromptForm is just a made-up form that asks a question and lets the user type in an answer. If the OK button was clicked (and it's DialogResult property is set to DialogResult.OK ), you return the answer; otherwise, you return null (again, just an example). Before the answer or null is returned, the form variable is disposed since the above translates to:
PromptForm form = new PromptForm();
try
{
}
finally
{
form.Dispose();
} In a try-catch-finally or try-finally, the finally block is always exectued even if an exception is thrown (the only case where it's not is when you call Environment.Exit , which unloads the CLR and only finalizers are called).
There are many other things you can do as well. I suggest you go to MSDN[^] and browse some of the articles about memory management and the CLR.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to write a new ColorTranslator class because it can't analyse the color string like "rgb(255,0,0)"
public class ExColorTranslator <br />
{<br />
public static Color ExFromHtml(string htmlColor)<br />
{<br />
...<br />
}<br />
}
but When I used the function ExColorTranslator().ExFromHtml(...) ,I had to write new ExColorTranslator().ExFromHtml(...)
How to use this function directly and need't construct a new ExColorTranslator() class? just like the class such as Pens ,ColorTranslator ,Brushes ... does
|
|
|
|
|
when i need to use a function directly, i just change it to static, but you've already done that... not sure...
|
|
|
|
|
luming1122334455 wrote:
When I used the function ExColorTranslator().ExFromHtml(...)
Leave out the parentheses after ExColorTranslator and it should work: ExColorTranslator.ExFromHtml(...)
|
|
|
|
|
I got it!
Thanks very much,
|
|
|
|
|
Hi I'm new to progrramming with C# and was looking for a way to send the VGA screen from my Toshiba e800 PDA (Win Mobile 2003 SE) to a CRT monitor. I have the appropriate hardware for connection between the PDA and monitor but would like to switch the monitor display on and off from within a C# progam.
Any help would be greatly appreciated.
Thanks,
Brett
|
|
|
|
|
Need help badly. Project is due by this midnight. I am using OLEdataadapter to connect Visual C# to a Access Database. How you set up a SearchCommand.
REALLY. Please Help.
Thank you,
Vickie B.
|
|
|
|
|
cant help you... dont know enough...
but good luck, know how sh*tty deadlines can be...
|
|
|
|
|
You can try to use a SQLcommand, then the sql code can be
"select something from somewhere where something = '" + this.textbox1.text + "'";
then use the OLDDataadapter to populate the dataset, and display the result.
Hope you understand, and can get it work.
anghp@yahoo.com
Feel free to contact through email or yahoo messenger.
|
|
|
|
|
hpAng wrote:
You can try to use a SQLcommand, then the sql code can be
No, you use the OleDbCommand when using the other classes in the System.Data.OleDb namespace like OleDbDataAdapter .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
How can i send a FILE with HttpWebRequest
I opened a StreamWriter with GetRequestStream()
But i have no ideia how to send a file :\ because in the page have a FileField ;\
Thanks.
|
|
|
|
|
Take a look at RFC 1867[^] which describes file uploads using HTTP.
For example, if you only need to upload a single plain text file, you cn set the HttpWebRequest.ContentType to "multipart/form-data; boundary=ABC123". You then get the request stream using HttpWebRequest.GetRequestStream and, to make things easier, pass that to a StreamWriter with whatever Encoding is appropriate (should be the same as the file encoding you're uploading, though multiple parts can have different encodings that would go into the "Content-type" header as "charset". You would write to the request stream writer like so:
--ABC123
Content-type: application/x-www-form-urlencoded
param1=value1¶m2=value2
--ABC123
Content-disposition: form-data; name="FileField"
Content-type: text/plain
This content is from a text document.
--ABC123-- Notice the intentional line breaks and how the last line ends with -- (the end of the MIME boundary).
Learning this is crucial to understanding how to HTTP and MIME works, and the RFC is actually quite easy to read (compared to many others I've read).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've learned how to connect, attach and detach my msde tables and databases.
Now I need to be able to make a call to sp_helpdb and get the return values from a C# applicaiton.
Can someone give me some help please?
Thanks,
cb
|
|
|
|