|
First, I would recommend downloading and installing either or both of the VS.NET add-ins (differ for VS.NET 2002 and 2003):There are, IMO, indespensible tools when working with WMI. They are add-ins to the Server Explorer of VS.NET and you can even generate typed wrapper classes for CIMv2 classes to add to your project, as well as just browse the classes (a default set is added during installation - you can always add more classes).
Looking at mine, I can give you few alternatives. You could infer that the drive is a CD-R or CD-RW from the Name property. If there's media in the drive, you can also determine if it's writable by checking the name of the MediaType library. A non-writable CD drive wouldn't recognize blank media correctly.
Finally - and probably the best way, is to check the Capabilities and <coded>CapabilityDescriptions property.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a network application consisting of a core class (and underlying class structure, of course) and a GUI Form. Now they run together as a Windows Applications.
However, I found it would be very suitable for this app to run as a Windows service in the background. The problem is: sometimes the user who happens to be logged on may need to interact with the service or check its state. I don't want to put a GUI in the service (that's not possible - it should run out of the user context), but have a separated GUI application that can be run and connected to the service process, check state, issue commands and then disconnected, with the service remaining active.
My question is, what communication means should I use? I thought about opening a local socket... is there another way? I've seen a couple of services with front-ends, how do services deal with this problems?
Thanks.
|
|
|
|
|
You can send simple commands (and I do mean simple) to the service via the ServiceController and it's ExecuteCommand method.
If this isn't suitable (really only good for telling the service to do pre-defined tasks), then the best way is using .NET Remoting. It may be a little difficult to understand at first, but once you understand it it's excellent. If you're familiar with XML Web Services, you've already got a pretty good start. .NET Remoting - unlike XML Web Services - doesn't really care about the transport or serialization channel (though there are some restriction depending on how the remoting object is hosted). The .NET FCL provides both a SoapFormatter and a BinaryFormatter , as well as a TcpChannel and HttpChannel . For the best performance, I recommend configuring your remoting object and the proxy (runs on the client) so that it uses the BinaryFormatter (faster serialization and much less overhead) and the TcpChannel for two-way communication and faster transport than HTTP.
There are lots of good articles here on CodeProject about .NET Remoting. I recommend anything by Roman Kiss (although some knowledge of .NET Remoting is required since his articles are often for more advanced developers with .NET Remoting).
You can also read about it in the .NET Framework SDK: .NET Remoting Overview[^].
I would also recommend 1 or both of the following books:The biggest advantage over using TCP sockets is that you don't have to define your own protocol; it's already done for you. You also don't have to worry about the serialization of complex objects. The one advantage of using a TCP socket with a solid protocol design is that you could communicate with it using just about any language, framework, or platform.
This is the typical and recommended solution for communication between .NET projects.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the answer!
My fear was exactly having to create a protocol to communicate.
I worked with web services in Java and know a bit about them, so it should not be a problem to understand remoting, I think. I'll read the articles.
Another doubt, will I be able to register to events on the server object, or will I have to stick with RPC pattern, making "poll" calls? Thanks again.
|
|
|
|
|
Depending on the two-way capabilities of the channel (as I mentioned previously) your remoting object (hosted by the Windows Service in this case) can fire events that the client can handle.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I want to display records of around 10,000 to DataGrid at run-time.
i.e. as data is availble, need to be disaplyed to DataGrid.
In my system all records are not available at same time, I have to fetch data in the packetes from another computer over network, and each packet containes 25 -50 records.
Data comes very fast at the rate of 100msec. when I try to display row wise, DataGrid gets blank till i finish all data updation.
Does any body knows how to handle this kind of problem?
Any help is appreciated.
Thanks in advance.
|
|
|
|
|
try to fetch the entire record first using any method and later bind the return type(dataset) of that method to datagrid.
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
Lock the DataGrid Painting during records population and then unlock the DataGrid. This will solve your problem. Refer the following code for details
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern Int32 LockWindowUpdate (Int32 hwndLock);
</br>
private void PopulateDataInGrid()
{
LockWindowUpdate(dataGrid1.Handle.ToInt32());
</br>
</br>
</br>
</br>
</br>
</br>
LockWindowUpdate(0);
}
Please revert back whether this solves your problem or not.
Regards,
Jay.
|
|
|
|
|
thanks, now performance is better.
|
|
|
|
|
Have any of you created any custom additions to Microsoft's HTML editor control? I have a bunch of features I'd like to implement, including:
- locking of certain portions of an html page so that only specified blocks can be edited. When the user tries to do anything, for example, selecting text, clicking a table, etc, they'd simply get a "not allowed" cursor icon and clicking a locked area would have no effect.
- a vastly improved table editor! I'd like to implement a table editor similar that functions similarly to dreamweaver's table editor. Microsoft's table editor sucks. Various things would need to be overridden, i'd imagine, including how tables respond to various events (click, drag, drop, etc).
Have you ever attempted anything like this? I'd really like to know what the limitations of the html editor control are before I start to invest a whole bunch of time trying to do these things only to come to brick wall halfway through development.
Also, I'm open to making this free if anyone wants to help me. Naturally I'll be using C# and implementing it as a custom winforms control.
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
What you want is possible, although not easy. You can host either the WebBrowser control or the MSHTML component through COM interop assemblies. The WebBrowser control hosts the MSHTML component and provides additional services you may want, like hyperlinking and additional communication with the host.
In order to extend it, you must declare managed interfaces like IDocHostUIHandler . These advanced hosting interfaces are documented in MSDN in the Advanced Hosting Reference[^]. If you want to generate an interop assembly for these interfaces, read the article Using MSHTML Advanced Hosting Interfaces[^] here on CodeProject.
If you don't want to go to all that work (because there's quite a bit involved), take a look at some of the third-party solutions out there. We just settled on the NET.RIX[^] component, which has both a full and lite version with what you want already. It's also affordably priced and royalty free.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Wow that NET.RIX control looks great! I think I'll go that way and save time. thanks
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
I just found this great free control at http://www.skybound.ca/developer/visualstyles/[^]. Has anyone tried/tested it? Is it reliable enough for deploying? I'm a little worried since it used something similar to Application.EnableVisualStyles();
Anyway... it's definately worth a look and a try because it is an amazing piece of software!
Carl
|
|
|
|
|
how can i save an image to a directory that i want with out using SaveFileDialog.
Thanks
Rock Throught The Night
|
|
|
|
|
The SaveFileDialog is only used to get directory path and the filename where you want to save the image into. It does not save your image into the directory.
If you already know where to save the image, you can specify the path directly to your function that writes the image file.
Edbert P.
Sydney, Australia.
|
|
|
|
|
once more question: how to get the file extension.
Thanks
Rock Throught The Night
|
|
|
|
|
string ext = System.IO.Path.GetExtension(path);
Don't people read help files anymore
|
|
|
|
|
In C#, there is a function called GetExtension that can return
extension name of a file given the file path.
Here's a sample code:
string fileName = @"C:\mydir.old\myfile.ext";<br />
string extension;<br />
<br />
extension = Path.GetExtension(fileName);<br />
Console.WriteLine("GetExtension('{0}') returns '{1}'", <br />
fileName, extension);
Hope it helps
Edbert P.
Sydney, Australia.
|
|
|
|
|
Hi,
Ok Heath mentioned that I should call dataset.Merge after I get a returning dataset from Webservice. Well the Compact framework doesn't support Merge property. So what should I use instead in order to update dataset on client to reflect change in returned dataset ?
Thanks,
JJ
|
|
|
|
|
Merging is only necessary if you have two distinct DataSet . IIRC, this was your case.
I would recommend downloading a decompiler like .NET Reflector[^] and see how the Merge method works. It does use an internal class that wouldn't be available in the .NET CF, either, but you could duplicate the functionality in your project.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If I am getting a dataset from a webservice on a different machine, couldn't I somehow clone the returned dataset back into the original dataset sitting on the client?
Design:
PDA client calls webservice sitting on other pc with database and IIS. I send dataset to webservice to have it update DB then return a dataset back to client.
Thanks,
JJ
|
|
|
|
|
A clone is a copy of the original, so how can you "hook it back up" to the original? As I said before, just merge the DataSet you get back with the one you have in memory using DataSet.Merge .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have written a PowerPoint Add-In and am working on the install package.
I created the setup project and am trying to set a registry entry to the location that the application is installed (whatever that may be).
I must do this to have access to the install directory as with COM add-ins all the application path properties in the Framework return *OFFICE's* application path, not my add-in's.
So in the registry part of the setup I have set several static values but also want to set one that is dynamic based on the install location.
Anyone know how to do this?
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
First of all, if these add-ins are .NET assemblies, you can always get their path using Assembly.GetExecutingAssembly().Location , among a few similar ways.
To set the path in the install, though, set the registry value to [INSTALLDIR] (more than likely, if all your assemblies go into the same installation directory). There are much better ways but the VS.NET Windows Installer project doesn't make them possible without using a tool like Orca (from the Windows Installer SDK) and modifying the MSI package after it's compiled, which also requires some knowledge about MSI packages.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I was wondering if you could have a public structure with private/public objects within it? Like in this example
<br />
public struct ClientData<br />
{<br />
public Socket clientSocket;<br />
public Thread clientThread;<br />
private int clientMonitorID;<br />
}
or if you define it as public does object within become public
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!
|
|
|
|