Hi,
How can I get the System class ImageList from C# application, I want to
receive this image list used in device manager ?
I find a C API :
WINSETUPAPI BOOL WINAPI
SetupDiGetClassImageList(
OUT PSP_CLASSIMAGELIST_DATA ClassImageListData);
How I can call this API from C# ?
Thanks
Joe 6 5263
"[Joe]" <Jo*@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
| Hi,
| How can I get the System class ImageList from C# application, I want to
| receive this image list used in device manager ?
| I find a C API :
|
| WINSETUPAPI BOOL WINAPI
| SetupDiGetClassImageList(
| OUT PSP_CLASSIMAGELIST_DATA ClassImageListData);
|
| How I can call this API from C# ?
|
| Thanks
| Joe
Not sure why you ever wanna use this from C# but here it goes:
[DllImport("setupapi.dll")]
static extern int SetupDiGetClassImageList(out PSP_CLASSIMAGE_DATA
ClassImageList);
public struct PSP_CLASSIMAGE_DATA {
public uint cbSize; // size of this struct
public IntPtr ImageList; // Handle
public uint Reserved;
}
don't forget to destroy the list when done (see
SetupDiDestroyClassImageList).
Willy.
Hello Willy,
Thanks this was very helpful , I still don't know how to convert this
handle to System.Windows.Forms.ImageList ?? , I watch in the Marshal class
but didn't figure how to do that. I will be so happy if you can help me also
in this issue .
Regards,
Joe
"Willy Denoyette [MVP]" wrote:
>
"[Joe]" <Jo*@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
| Hi,
| How can I get the System class ImageList from C# application, I want to
| receive this image list used in device manager ?
| I find a C API :
|
| WINSETUPAPI BOOL WINAPI
| SetupDiGetClassImageList(
| OUT PSP_CLASSIMAGELIST_DATA ClassImageListData);
|
| How I can call this API from C# ?
|
| Thanks
| Joe
Not sure why you ever wanna use this from C# but here it goes:
[DllImport("setupapi.dll")]
static extern int SetupDiGetClassImageList(out PSP_CLASSIMAGE_DATA
ClassImageList);
public struct PSP_CLASSIMAGE_DATA {
public uint cbSize; // size of this struct
public IntPtr ImageList; // Handle
public uint Reserved;
}
don't forget to destroy the list when done (see
SetupDiDestroyClassImageList).
Willy.
"[Joe]" <Jo*@discussions.microsoft.comwrote in message
news:9E**********************************@microsof t.com...
| Hello Willy,
| Thanks this was very helpful , I still don't know how to convert
this
| handle to System.Windows.Forms.ImageList ?? , I watch in the Marshal class
| but didn't figure how to do that. I will be so happy if you can help me
also
| in this issue .
|
That's what I was affraid of, Forms.ImageList is a class while the
setupapi.dll API returns a Handle, there is no way to convert this to an
ImageList nor to contruct an ImageList from a Handle. The setup library is
not meant for general consumption, it is meant to be used to build your own
device setup applications (using C++) using your own image lists. If you are
trying to implement device installers using C# you will have a hard time as
you'll have to use all API's in the set. If you are only trying to use the
images in the setupapi.dll ,you only have to call SetupDiDrawMiniIcon using
this import definition:
[DllImport("setupapi.dll")]
static extern int SetupDiDrawMiniIcon(IntPtr hDC, Rectangle rec, int index,
uint flags);
but honestly I don't see why you ever wanna do this.
Willy.
what I'm tring to display my devices in treeview and set the image depending
on the Class type .
"Willy Denoyette [MVP]" wrote:
>
"[Joe]" <Jo*@discussions.microsoft.comwrote in message
news:9E**********************************@microsof t.com...
| Hello Willy,
| Thanks this was very helpful , I still don't know how to convert
this
| handle to System.Windows.Forms.ImageList ?? , I watch in the Marshal class
| but didn't figure how to do that. I will be so happy if you can help me
also
| in this issue .
|
That's what I was affraid of, Forms.ImageList is a class while the
setupapi.dll API returns a Handle, there is no way to convert this to an
ImageList nor to contruct an ImageList from a Handle. The setup library is
not meant for general consumption, it is meant to be used to build your own
device setup applications (using C++) using your own image lists. If you are
trying to implement device installers using C# you will have a hard time as
you'll have to use all API's in the set. If you are only trying to use the
images in the setupapi.dll ,you only have to call SetupDiDrawMiniIcon using
this import definition:
[DllImport("setupapi.dll")]
static extern int SetupDiDrawMiniIcon(IntPtr hDC, Rectangle rec, int index,
uint flags);
but honestly I don't see why you ever wanna do this.
Willy.
"[Joe]" <Jo*@discussions.microsoft.comwrote in message
news:F5**********************************@microsof t.com...
| what I'm tring to display my devices in treeview and set the image
depending
| on the Class type .
|
|
Well as I said, you need to call some more API's.
First you'll have to call:
SetupDiClassGuidsFromName
to get the list of Guid's corresponding to the device class,
using the right Guid in the list you'll have to call:
SetupDiLoadClassIcon
the returned HICON can then be used to construct an Icon instance which can
be used in your treeview.
To get you started here is a code snip that shows you how to get at the
device icon using the classGuid....
static extern int SetupDiLoadClassIcon(ref Guid classGuid, out IntPtr hIcon,
out int index);[DllImport("setupapi.dll")]
....
IntPtr hIcon;
int ix;
// Here the "DiskDrive" deviceClass GUID
//4D36E967-E325-11CE-BFC1-08002BE10318
Guid guid = new Guid("{0x4D36E967, 0xE325, 0x11CE,{0xbf, 0xc1, 0x08, 0x00,
0x2b, 0xe1, 0x03, 0x18}}");
if(SetupDiLoadClassIcon(ref guid, out hIcon, out ix) != 0)
{
// Ok, Icon found
// Create graphics object for alteration.
// Create a new icon from the handle.
Icon devIcon = Icon.FromHandle(hIcon);
...
}
Willy.
Thanks a lot .
"Willy Denoyette [MVP]" wrote:
>
"[Joe]" <Jo*@discussions.microsoft.comwrote in message
news:F5**********************************@microsof t.com...
| what I'm tring to display my devices in treeview and set the image
depending
| on the Class type .
|
|
Well as I said, you need to call some more API's.
First you'll have to call:
SetupDiClassGuidsFromName
to get the list of Guid's corresponding to the device class,
using the right Guid in the list you'll have to call:
SetupDiLoadClassIcon
the returned HICON can then be used to construct an Icon instance which can
be used in your treeview.
To get you started here is a code snip that shows you how to get at the
device icon using the classGuid....
static extern int SetupDiLoadClassIcon(ref Guid classGuid, out IntPtr hIcon,
out int index);[DllImport("setupapi.dll")]
....
IntPtr hIcon;
int ix;
// Here the "DiskDrive" deviceClass GUID
//4D36E967-E325-11CE-BFC1-08002BE10318
Guid guid = new Guid("{0x4D36E967, 0xE325, 0x11CE,{0xbf, 0xc1, 0x08, 0x00,
0x2b, 0xe1, 0x03, 0x18}}");
if(SetupDiLoadClassIcon(ref guid, out hIcon, out ix) != 0)
{
// Ok, Icon found
// Create graphics object for alteration.
// Create a new icon from the handle.
Icon devIcon = Icon.FromHandle(hIcon);
...
}
Willy.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: A. Solomon |
last post by:
Hi,
I have a ImageList containing 4 bitmaps attached to a UserControl
which acts as a Open/Close panel.
This panel, upon click, switches the image in a PictureBox control to
indicate the...
|
by: Bob C. |
last post by:
Hi All,
I am using the ImageList/ListView Components to display around 100 images
in C#.NET.
The issue i have is, some times i may need to display the thumbnail of size
more then 256x256 in...
|
by: Sanjeeva Reddy |
last post by:
hai Anti Keskinen,
i have used
the following code MyListView->LargeImageList->ImageSize = gcnew
System::Drawing::Size(100,
100); // Sets large image size to 100, 100
here i am getting error...
|
by: Andrew Christiansen |
last post by:
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on
a treeview control. I have the imagelist on the form filled with images,
and have the ImageList property of the...
|
by: David |
last post by:
I have a problem that just cropped up with using an ImageList in my project
I am using VB .NET 200
Problem:
I have existing Form with 2 Image List controls. ImageList16 (for 16x16 Images) and...
| |
by: Just Me |
last post by:
If I add an image to an imagelist using
imageList.Images.Add...
And use it with a tree node
tn.ImageIndex = imageList.Images.Count-1
This is the actual code:...
|
by: Andre Viens |
last post by:
Hello,
I am using the following variation of code from
<http://support.microsoft.com/default.aspx?scid=kb;EN-US;319340> to add icons
to an imagelist for use in a listview:
Private Structure...
|
by: Ryan Liu |
last post by:
Hi,
If I extend a user control, do I need to so something for its resource file,
like ImageList used in parent class?
I ask this question because I often get inconsistent problem with images...
|
by: =?Utf-8?B?S2VuTg==?= |
last post by:
We're using a System.Windows.Forms.ImageList to store a bunch of Images that
I've loaded, and rendering each image in the ImageList during a draw loop.
The process was running unusually slow and...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |