|
Based on the devices that I have, I figured out that you can expect a USB Flash Drive to have PDCAP_D2_SUPPORTED under "Power data" in Device Manager, but not a memory card.
So I used a PInvoke to DevicePowerEnumDevices in PowrProf.dll ( http://msdn.microsoft.com/en-us/library/aa372681(VS.85).aspx[^] ). That allowed me to filter by the device name in Win32_DiskDrive.Model and the PDCAP_D2_SUPPORTED flag.
|
|
|
|
|
Sounds reasonable. This would probably correspond to a 'spin-down' on USB disks, which makes no sense on flash cards (they are only required to support D0 and D3, fully ON and fully OFF). Wonder what an SSD would have in this case?
|
|
|
|
|
Actually, this doesn't seem to be working.. I thought it was, but I must have been mistaken. The internal card readers don't support D2, but the external card readers do.
|
|
|
|
|
I figured out what I did wrong --- you have to do a check on the Logical Disk name, not the Disk Drive name. The Disk Drive for the card reader supports more power states, and the Portable Device (listed in Device Manager) supports even more, including D1.
|
|
|
|
|
Except that only seems to work for one flash drive I have and not another. I'll continue to investigate that.
|
|
|
|
|
It was my error; the problem was it didn't find a drive with that drive letter because it was referring to the Portable Device, and thats listed by the Volume name if there is one.
But I finally found something that works! If you enumerate the hardware ID strings for the devices that support D2, the only ones that show up are the ones for flash drives. The memory cards are enumerated I think, but a query for the hardware ID returns an empty string. So you have to find the PnPEntity associated with the DiskDrive, and take the first indexed HardwareID.
No problems with this so far..
|
|
|
|
|
Just so people reading this know... it turns out the original solution I found is working again. I don't know if it was a glitch in how my system was reporting the information or whether the second, more thorough method is just more fool-proof. I'm getting the power data through setupapi.dll rather than through powerprof.dll though, since I'm trying to move away from WMI.
|
|
|
|
|
Hi all ,
I want to pass the table name as parameter to the method to obtain the result.
The code is as follows:-
<br />
private static String GetText(int id , String tableName)<br />
{ <br />
tbTest myTest = new tbTest();
<br />
myTest = dataContext.tbTests.Single(table => table.Test_id == id);<br />
<br />
return myTest.Test_Text;<br />
<br />
}<br />
Is there anyway where-in I can pass the id and table name to obtain the corresponding text (probably by strings ??) ?
I hope it makes sense.
thanks,
|
|
|
|
|
What? Is this a database question? We need more information.
|
|
|
|
|
I want to create and execute a dynamic query in the method by passing in the table name and ID.
I hope it makes sense.?
|
|
|
|
|
It makes sense, but it isn't enough information.
|
|
|
|
|
Please let me know wat info do u require?
<br />
private static String GetText(int id , String tableName)<br />
{ <br />
<br />
tbTest myTest = new tbTest();
<br />
myTest = dataContext.tbTests.Single(table => table.Test_id == id); <br />
<br />
return myTest.Test_Text;<br />
<br />
}<br />
I want the code to return the appropriate Text depending on the parameters passed ie tableName and ID
|
|
|
|
|
What you've presented is gibberish to me.
I want to know what you are trying to accomplish, not how you are trying to accomplish it (especially if it doesn't work).
0) Is there a database?
1) Is there a table in the database?
2) Are you trying to retrieve some information from that database table?
3) What is the schema of the table?
|
|
|
|
|
If you mean that the parameter tableName will be the name of class whose object you need to create, you can make use of reflection.
|
|
|
|
|
Reflection? I havnt used that before...can u elaborate on it plz. Thanks
|
|
|
|
|
|
Hi,
I am trying to set the IPConnectionMetric parameter of a network adapter in Windows 7. The method that I need to use is the "SetIPConnectionMetric" in the Win32_NetworkAdapterConfiguration class.
The problem is that the method returns an error code of 91 - Access Denied in Windows 7. However, this method works fine on Windows XP.
Can someone give me pointers to a solution? I played around with the Local Security Policies, but couldn't find anything
Here is more information about the method: http://msdn.microsoft.com/en-us/library/aa393303%28v=VS.85%29.aspx[^]
Thanks,
Karthik
|
|
|
|
|
Hi dear fellow developers,
I'm developing a new subsystem, where I need a list of search results. The list will contain more or less different object types, and as in ListBox I need the ability to click on the listed object, which can send the selected object to the propriated GUI; e.g.:
-------------------------------------
| <Adress object> |
| <Customer object> |
| <Customer object> |
| <Customer object> |
| <Adress object> |
| <Customer object> |
-------------------------------------
When clicking on Customer object, the customer gui will be shown with the selected object information inside. And when clicking on Adress object the adress gui will be shown with the selected object information inside, and so forth will all type of objects on the list.
I have looked at following lists:
Listbox:
This form of list couldn't make the tab index for making overview of different objects easier (As an last chance, I could use different colors, but the tabs wouldn't work still).
TreeView:
The view form are perfect and easy to make an overview with, but it seems like an disanvantage when getting to the click events, since it doesn't have the "SelectItem" object function.
ListView:
Havn't seen much on this one yet. Sounded like an solution to my needs, but doubt since it seems to have the split screen information, which showing information or contains of the left screen selection.
Any with some experience who could calculate which type of list for my needs here? Please help.
Best regards
|
|
|
|
|
I do not fully understand your objection to the TreeView Control.
Consider any of the many C# Explorer clones you can find on the web. They all have a TreeView in one pane and when you click on any of the nodes the appropriate information is displayed in another pane. It doesn't matter whether a Folder node or a File node is clicked.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
the whole idea with using TreeView, is to have Aparment object as parent, and customer names as children. When the user db. click apartment object, the apartment GUI will open with the selected object information in the apartment information fields. And if the user db. click customer, the customer GUI will open with the selected customer information filled into the fields.
Did it make it any clear, or still confusion about my use of the treeview?
|
|
|
|
|
grmihel2 wrote: TreeView ... doesn't have the "SelectItem"
You can store the item in the Tag property, that's what I do.
|
|
|
|
|
I'll try to use the tag function then, and see how it works. I'm used to ListBox's and items in it, so I think it just need another pov to understand the TreeView with tags. But thnx for your suggestion.
|
|
|
|
|
TreeView's way is better.
|
|
|
|
|
Ye I guess it might be, when you first explore the way they work, and figure tag functions
|
|
|
|
|
So, I gave this a try today for my ImageViewer UserControl (See my articles for more detail on it). And people have requested me to implement Multi-Page TIFF support.
Now I have been trying lots of different techniques for it but none of them seem to really work. My UserControl accepts images in 2 different ways. By passing in a FilePath or an Image through properties. Both these properties end up with having storing the image into a Bitmap.
Now this Bitmap is used in my Draw methods and if I try to do a SelectActiveFrame() it crashes on me with GDI+ An generic error has occured ExternalException (0x80004005).
What I tried to do is creating a new Bitmap of the original and then doing the SelectActiveFrame() and that did not crash. However it did not display either.
Here is a sample of my code from my DrawObject class:
pages = this.bmp.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
currentPage = 0;
if (pages > 1) { multiPage = true; } else { multiPage = false; }
public void NextPage()
{
try
{
if (this.bmp != null)
{
int nextPage = this.currentPage + 1;
if (nextPage <= this.pages)
{
Bitmap myImg = new Bitmap(this.bmp);
myImg.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, nextPage);
this.bmp.Dispose();
this.bmp = null;
this.bmp = myImg;
currentPage = nextPage;
}
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("ImageViewer error: " + ex.ToString());
}
}
And here is the code that calls the NextPage() function:
drawing.NextPage();
pbFull.Refresh();
UpdatePanels(true);
And PreviousPage() is exactly the same but with a minus ofcourse.
Any help would be much appreciated, I've been staring at it for hours now
|
|
|
|