• Advertisement
Sign in to follow this  

Unity Detecting an USB.

This topic is 4251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I have the same requirement as in the thread at http://www.gamedev.net/community/forums/topic.asp?topic_id=362845&whichpage=1� I wish to determine the type of removable drive, when the drive letter is given. To detect an USB (as per MSDN), I use the 'SetupDiGetDeviceRegistryProperty' method with SPDRP_REMOVAL_POLICY as a parameter. (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devinst_r/hh/DevInst_r/di-rtns_a60fa017-1c15-45bf-a178-37516bc0aea1.xml.asp) MSDN says: "SPDRP_REMOVAL_POLICY (Windows XP and later) The function retrieves the device's current removal policy as a DWORD containing one of the CM_REMOVAL_POLICY_Xxxx values defined in cfgmgr32.h." My problem: How does this function retrieve this value ? The Output parameter PropertyBuffer is of type PBYTE and when I type cast it and take the value as *((DWORD *)PropertyBuffer), it gives me an invalid value (some garbage other than the CM_REMOVAL_POLICY_ values defined in cfgmgr32.h) Can someone please help ?? Thanks, Vinoth

Share this post


Link to post
Share on other sites
Advertisement
You optimistically misunderstood the MSDN explanation.
Says an easily googled MSDN page:
Quote:
Return Value

SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. Otherwise, it returns FALSE and the logged error can be retrieved with a call to GetLastError. SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.


So the return value is a generic status code; the important "result" is written into a team of output parameters:
Quote:
PropertyRegDataType
Supplies a pointer to a variable to receive the data type of the property being retrieved. This is one of the standard registry data types.

PropertyBuffer
Supplies a pointer to a buffer to receive the property being retrieved. If set to NULL, with PropertyBufferSize set to zero, the function just returns a value for RequiredSize.

PropertyBufferSize
Supplies the length, in bytes, of PropertyBuffer.

RequiredSize
Optional. If not NULL, it is a caller-supplied pointer to a variable that receives the required size, in bytes, of the property buffer pointed to by PropertyBuffer, based on the property requested by Property.


Isn't it a cute API?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Now

  • Advertisement
  • Similar Content

    • By RoKabium Games
      Custom coffee mugs have arrived... More caffeine!
      Have a great weekend everyone! 
      #gamedev #indiedev #sama #caffeine
    • By Atwo Studios
       
      Hey guys,

      Anthony here from Atwo Studios bringing you some new updates for the new year!
      In this video I go over our game ROY, the new games and some general updates to the company!

      If you have not checked out ROY feel free to give it a try! Many people have said they enjoyed the game thus far!
      ROY: https://goo.gl/o6JJ5P
       
    • By Affgoo
      https://play.google.com/store/apps/details?id=com.NE.Alien
      still a lot of work to do, but its pretty stable  please let me know what you think <3
      Atlas Sentry is a game of destroy everything. Using your turret, simply swivel and shoot your way to victory, upgrading your weapons to unleash destruction on the variety of spaceships. The bigger your combo’s the more score you get! Earn silver as you play and then purchase new weapons and abilities to better deal with your enemy. Different enemies use different tactics and weapons, work out your own priorities in their destruction order. 

      Features: 
      **2 different game modes 
      **A level select mode with 20 difficult levels including a final boss, can you defeat it? **Arcade mode of endless destruction, how long will you last? 
      **High scores to compete against others, see who can take the top spot. 
       
    • By Chamferbox
      Chamferbox, a mini game asset store has just opened with some nice game assets, 
      Here you can find a free greek statue asset 

      Also check their dragon, zombie dragon and scorpion monster out:



      They're running the Grand Opening Sale, it's 30% off for all items, but for gamedev member, you can use this coupon code:
      GRANDOPEN
      to get 50% off prices What are you waiting for, go to
      http://chamferbox.com
      and get those models now!

      View full story
    • By Dafu
      FES Retro Game Framework is now available on the Unity Asset Store for your kind consideration!
      FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
      So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
      Some FES features:
      Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
      FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
      Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
      I hope I've tickled your retro feels!



      More images at: https://imgur.com/a/LFMAc
      Live demo feature reel: https://simmer.io/@Dafu/fes
      Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
      Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064

      View full story
  • Advertisement