Does anyone out there know of a way to tell the difference between USB flash drives through code? I can catch the USB Flash drive being connected, find out the drive letter, and find out the registry mounted drive information but if you have two of the exact same USB flash drives this information is the same if you connect them one at a time. I need to find a way to tell the difference between the two identical flash drives. Thanks in advance.
Thank you for the suggestion but after doing some research and testing, I found that GetVolumnInformation does indeed give me a unique serial number but the serial number changes everytime you format the drive. This will probably work for me, but it's not water proof. I need to create a list of valid USB flash drives in my program for security purposes. If the user formats the drive down the road, the new serial number won't be in the list. I found this example: http://www.thecodeproject.com/csharp/hard_disk_serialNo.asp[^] but it only seems to work for Windows XP and doesn't seem to work well with USB flash drives.
I'm not sure what's going on here. First off you do not seem to be running off the end of the vector since your loop is using i<size. You do not have to initailise the BSTR to NULL - The idl of IHTMLElement::tagName looks something like this:
Notice the out attribute - This parameter is only marshalled one way. You are leaking BSTRs however, you should be calling SysFreeString(tagName) to free the old before you get a new one. This will not cause a crash however - Just leak memory. Can you provide more information? The type of exception and the code which fills the vector and perhaps a stack trace of the crash?
Sorry I'm not sure whether this has been asked before. Will appreciate it if someone points out to me how to run a search through this forum.
I have an application that draws a rectangle across my viewport(a rectangle in a dialog box) by the standard operation (left mouse down, left mouse held, mouse goes right, mouse up). A rectangle of height of my viewport will be drawn starting from the point.x value where the mouse is clicked to where it is released. but recently i notice a problem in that since my viewport in my dialog is limited, if i shift the mouse at a reasonable speed, it seems to be unable to draw a full rectangle from the start point to the end point. It seems to end prematurely at some random point before the extreme right end. But there is no such problem if i move my mouse slowly. I believe changing the way i handle mouse down, mouse move and mouse up can handle this prob.
But curious and troublesome me just want to know, wat is the frequency that the mouse moving message is sent to Windows? Or could the complexity of my app be the reason behind this problem? Thanks for any answer!!
Thanks Phil for teaching me about SetCapture. Have nv encountered it beforein my short programming experience.
But maybe to make my problem clearer, it's not about capturing mouse position in a sense. I'm more curious about how often is this mousemove message sent out. For example, every second? every millisecond? every pixel?
It's just a question that suddenly popped into my brain...because i can draw a rectangle within a rectangle nicely if i shift the mouse at a slightly slower or normal speed( depending on how you perceive it). But if i am to slowly approach the boundary of my drawing area (a rectangle) within my dialog box, and near the end suddenly increase the speed of shifting my mouse, suddenly zooming past the extreme right of my drawing rectangle (and not my dialog), the rectangle drawn will not be covering a certain area on the right of my drawing area.
I tried it a few times, and notice it's pretty random, as in the area left undrawn, despite my mouse moving over it, is always changing.
Hence this question:
Is the mousemove msg sent every sec, every pixel or what?
i want to make a MFC application which only should have a tray icon and a popup menu (accessible via the tray icon). but i don't know what kind of application i should choose. should i make a dialog based or a sdi one ? i mean i only need the message map.
If you only need a message map, I suggest that you don't use MFC at all. Just using plain old WIN32 APIs frees you from loading DLLs and eases the deployment.
If this is no problem, you should use the SDI application. Simply removing the dialog class is not enough as you need a window to have a message map. You can also use some handy classes here on CP for tray icons.
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
yes, i have to use MFC because there are some classes in my app which need it.
creating the tray icon and the popup is no problem. i only have to bother with getting rid of unnecessary dialogs and/or windows. the result should be a MFC based application with only a tray icon and a popup menu as its GUI - neither a dialog nor a window can be visible.
aren't there any sample codes out there? i can't believe that i'm the first one who's trying this.
here's what i have done: i've used a simple MFC dialog based application. i used to start it in InitInstance with RunModalLoop() and set the visible mode of the dialog in the resource editor to false. In the CDialog derived class i've overloaded the function OnCreate and added the following Window Style:
ModifyStyleEx(0, WS_EX_TOOLWINDOW );
and, well, it works: NO WINDOW. NO DIALOG. NO TASKBAR ENTRY. AND I STILL GOT MY MESSAGE MAP
I have a large, complex app MFC with /CLR, Unicode, uses several dll's including one .NET assembly.
Release build works perfectly on dev machine.
Deployed to target machine with .NET Framework 2.0 and all necessary dependencies. It crashes immediately every time in kernel32.dll with exception 0x406d1388. Further examination with depends.exe shows that the caller was advapi32.dll but I can't get much more info.
This happens on WinXP SP2 and on Win2k SP4.
It seems that the exception is the one normally used to set a thread name so it makes no sense to me that it's causing a crash.
If I run the app (same release version) by remote debugging from VS2005 it all works properly.
I've built a simpler test app to try to reproduce use as much as possible of the same environment (MFC, CLR, dll's and so on) and it also works perfectly.
The problem seems to occur at some stage in the runtime initialisation.
If I run the programme under VS2005 it won't fail. I set it to break on the exception but it never sees it.
If I jit debug it the process wakes up and continues faultless as soon as the debugger attaches.
WinDbg sometimes sees the exception but I can't get any sense out of the call stack. I can't set breakpoints using WinDbg because it corrupts the code somehow and complains about "invalid x86 breakpoint in IL stream".
Any ideas ... ?
Last Visit: 31-Dec-99 19:00 Last Update: 1-Dec-23 9:47