|
Thank you for your reply. I will mess around with your example to see if it gives me any other leads but I don't think I will be able to use it for my application. The application I am writing needs to be able to run on any client computer running Win98, Me, 2000, or XP. I don't think I will be able to guarantee WMI on the computer in which the app is installed.
I don't know much about WMI, so if my statements above are not true let me know.
Mark Sanders
sanderssolutions.com
|
|
|
|
|
WMI is available only as an add on to Win98 so this is not a good solution for you. I figured the platform would be a problem with this answer but thought I would post anyway.
Matt is a network administrator for an insurance company in the midwest. He is shamelessly looking for Windows programming side work.
|
|
|
|
|
|
>
Hey! i just checked out ur email so I am answering. The other way:
>
//Get Drive list...getDrives() implementaion last lines...
ManagementObjectCollection queryCollection = getDrives();
//Loop Here...Iterate through each Node....
foreach ( ManagementObject mo in queryCollection)
{
switch (int.Parse( mo["DriveType"].ToString()))
{
case 2: //removable drives = 2 (A:\)etc...
numberofRemovable++;
break;
case 3: //Local drives (C:\;D:\;E:\)
numberofLocalDisk++;
break;
case 5: //CD rom drives(F:\;G:\)
numberofCD++;
break;
case 4: //Network drives
numberofNetworkdrv++;
break;
default: //default to folder
break;
}
//objects = ArrayList Object here..
objects.Add(mo["Name"].ToString);
}//loop end
/////////////////////////////////////////////////////////
///
/// Gets the lists of the logical disks and their infos..
/////////////////////////////////////////////////////////
protected ManagementObjectCollection getDrives()
{
//get drive collection
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * From Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();
return queryCollection;
}
///////////////////////////////////////////////////////////
I hope this will work for ur application too...
regards,
fahad...
I wish not to seem but to be the Best....
F a h a d H. Siddiqui
|
|
|
|
|
Hi,
I am using a vender-provided COM object in a C# Windows
Forms application to extract proprietary data format from
an AD attribute. The data is stored in an associative
array. The problem I am having is retrieving the items
that the object returns as its parameters. For example,
upon binding to an AD container object, the object creates
an instance of type Scripting.Dictionary within COM
object, and exposes this instance as a property
called "Parameters." I've tried casting to a ListDictionary,
HybridDictionary, you name it. Nothing seems to work except
IEnumerator.
The problem I'm having is how to retrieve the items for
each key in the Scripting.Dictionary collection. I'm able
to retrieve the names of the keys, but now I simply want
to get the values for each key, called "Items". I've wrapped
the Scripting.Dictionary class into a .NET assembly using
the TLBIMP libary and included it in my project. Here's a
snippet of my code so far:
// AD path to bind to
string ADsPath = "LDAP://CN=Some List,OU=Distribution
Lists,DC=DomainA,DC=CorpA,DC=com";
// instantiate the vender COM object
AGQueryClass ag = new AGQueryClass();
// bind to the AD path
ag.Set(ADsPath);
//cast ag.Parameters to Scripting.Dictionary instance
Scripting.DictionaryClass sd = (Scripting.DictionaryClass)
ag.Parameters;
// get collection enumerator
IEnumerator IEn = sd.GetEnumerator();
// array to hold keys
Array ary = Array.CreateInstance(typeof(object), sd.Count);
IEn.Reset();
IEn.MoveNext();
// populate the array with key names
for (int i=0; i
|
|
|
|
|
Try this:
using System;
using System.Collections;
using System.Collections.Specialized;
public class ScriptingUtils
{
public static IDictionary ConvertDictionary(Scripting.IDictionary dict)
{
HybridDictionary ret = new HybridDictionary(dict.Count);
foreach(object k in dict)
{
object key = k;
object value = dict.get_Item(ref key);
ret.Add(key, value);
}
return ret;
}
} You can then change your code to:
using System;
using System.Collections;
...
string ADsPath = "LDAP://CN=Some List,OU=Distribution Lists,DC=DomainA,DC=CorpA,DC=com";
AGQueryClass ag = new AGQueryClass();
ag.Set(ADsPath);
IDictionary dict = ScriptingUtils.ConvertDictionary(
(Scripting.IDictionary)ag.Parameters);
object[] keys = new object[dict.Count];
object[] values = new object[dict.Count];
int index = 0;
foreach(DictionaryEntry entry in dict)
{
keys[index] = entry.Key;
values[index] = entry.Value;
index++;
}
...
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Yes, that did it! Thank you Richard.
|
|
|
|
|
I may be being thick but I'm having problems using .CreateInstance
Dim ty As Type<br />
ty = Type.GetType("System.Windows.Forms.Textbox", True, True)
You'd think it would return a textbox type! But it errors beacuse it's trying to look for the textbox in my namespace:-
Could not load type System.Windows.Forms.TextBox from assembly xmlForms
Any ideas?
|
|
|
|
|
No, Type.GetType() won't return a TextBox , it'll return a Type . That Type is defined in the System.Windows.Forms assembly. Since you didn't get an assembly reference, the class is assumed to be in your assembly, *not* your namespace. Namespaces can span assemblies and vice-versa.
If you need to get a Type from a string, you need to specify the fully qualified assembly info, like so:
Type t = Type.GetType("System.Windows.Forms.TextBox, System.Windows.Forms, " +
"Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", true, true);
That'll tell the type loader to get that type out of the System.Windows.Forms assembly, no yours. If an assembly is in the GAC, you can just specify the fully qualified classname and the assembly. The type loader will use the latest version of that assembly. If an assembly is not in the GAC, you have to specify all type properties or use a publisher policy to to specify which version and from where the assembly comes.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Thanks Heath, that works
|
|
|
|
|
Hi
i would like to disable/hide the Close button "X" on the upper left corner, also the hot keys like control + F4, to close mdi child, should be disabled. I like to group some mdi childs, and only one child should be enabled to close. This childs than close the other ones.
Is there any way under c# ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
To keep the window from closing, handle the Form.Closing event and set the CancelEventArgs.Cancel member to true . As far as disabling the Close button, MSDN suggests removing the Close system menu item from the control bar. To do this, you'll need to P/Invoke GetSystemMenu from user32.dll and RemoveMenu from user32.dll. See "Q184686" in Microsoft KB. It's in VB, but the concept is the same.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
thanks, i will take a closer look ,)
.:Greets from Jerry Maguire:.
|
|
|
|
|
It's easy, just set ControlBox to false, and the Close Menuitem and Button are disabled.
.:Greets from Jerry Maguire:.
|
|
|
|
|
i have never used toolbars before...so humor me ( i have never needed them) anyways how can i seperate my buttons with just a panel on my tool bar.. kinda like MenuItem jr = new MenuItem("-"); in the menu. anyways thanks for the time
Cheers,
jesse m
|
|
|
|
|
if i get you right, you wish to use the System.Windows.Toolbar Control, you create a new button and set his style to "Separator" or something similiar like that.
.:Greets from Jerry Maguire:.
|
|
|
|
|
Hi,
how can i subclass office apps, that they run in my own form ?
something like
officeApp.DockStyle = Fill;
officeApp.Parent = myForm;
does somebody had a sample or a link about this ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
How can I draw lines and shapes with GDI+ on a pictureBox device and save or export my drawing to an image file (*.bmp,*.gif) on the disk?
I tried the "Image.Save()" method but it didn't save what I draw...
Moshu
|
|
|
|
|
Create your Bitmap (does not mean .bmp file) from a Graphics object using the Bitmap(int, int, Graphics) constructor (or, if your Graphics object was created from the Bitmap, do nothing) and use Bitmap.Save specifying a PixelFormat of whatever image type you want (and is supported).
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Is it possible to open up MS Project2000 files inside a windows form. I can open up a word document inside a form by using the AxWebBrowser. Is there any control or something for doing this?
|
|
|
|
|
I'm referencing a DLL in a C# application and it works fine(Both a forms and console app tested successfully). However, I wish to expose the DLL VIA SOAP. For some reason, the DLL just fails. It doesn't work .. Any ideas ?
Its a DLL from Novell that authenticates users and can transverse a NDAP directory. It was meant to be called from VB6.
Is it wrong to think "if it works in the app it can be referenced and exposed via S.O.A.P ??
Any ideas ??? Anyone ?
|
|
|
|
|
I am looking for a way to send a float[,] accross a tcp/ip socket connection.
Can I convert this to a byte[] somehow without itterating through each element?
Is there some easier way than using a NetStream?
Thanks for your assistance.
(I would like this to work for Arrays up to 30 million elements)
Deane
|
|
|
|
|
These static functions will allow you to create byte[]s from the float[,]s and then convert them back.
<br />
using System;<br />
using System.Runtime.Serialization.Formatters.Binary;<br />
using System.IO;<br />
<br />
public class Utility<br />
{<br />
public static byte[] TwoDFloatArrayToByteArray(float[,] floats)<br />
{<br />
MemoryStream mem = new MemoryStream();<br />
<br />
BinaryFormatter bf = new BinaryFormatter();<br />
<br />
bf.Serialize(mem,floats);<br />
<br />
return mem.ToArray();<br />
}<br />
<br />
<br />
public static float[,] ByteArrayToTwoDFloatArray(byte[] bytes)<br />
{<br />
MemoryStream mem = new MemoryStream(bytes);<br />
<br />
BinaryFormatter bf = new BinaryFormatter();<br />
<br />
float[,] floats = (float[,])bf.Deserialize(mem);<br />
<br />
return floats;<br />
}<br />
}
I can't really help you with the TCP/IP problem. All I can say is "Compress those byte[]s before transmission!". 30 million floats is 120mb... Hope you have a fast connection.
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thank you very much, that looks like exactly what I was looking for.
Compression is definitely next on the todo list and should prove to be quite effective given the sparse nature of the data.
Deane
|
|
|
|
|
For a compression library, check out SharpZipLib[^]. This is an easy to use library and is very good using standard algorithms. It is completely written in C#.
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|