Jump to content

AwAke

Active Members
  • Posts

    99
  • Joined

  • Last visited

About AwAke

  • Birthday 09/05/1991

Profile Information

  • Location
    Liverpool, United Kingdom

AwAke's Achievements

Wayfarer

Wayfarer (2/7)

1

Reputation

  1. To detect the insertion of a USB drive use this code. Its similar to the C# example you posted. $strComputer = "." $objWMIServices = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $sink = ObjCreate("WbemScripting.SWbemSink") ObjEvent($sink, "SINK_") $objWMIServices.ExecNotificationQueryAsync($sink, "SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " & "TargetInstance ISA 'Win32_LogicalDisk'") ;- End of setting up the WMI event ---------------- ;- The event that is called upon detecting a USB storage device. Func sink_OnObjectReady($objObject, $objAsyncContext) Local $choice If $objObject.TargetInstance.DriveType = 2 Then ;- TargetIstance.DriveType = 2 means a Removable drive. Select Case $objObject.Path_.Class () = "__InstanceCreationEvent" ;- Storage Device is plugged in. ConsoleWrite("Drive " & $objObject.TargetInstance.DeviceId & "has been removed." & @CR) Case $objObject.Path_.Class () = "__InstanceDeletionEvent" ;- Storage device has been removed. ConsoleWrite("Drive " & $objObject.TargetInstance.DeviceId & "has been removed." & @CR) EndSelect EndIf EndFunc Credits goes to wolf9228 here -> http://www.autoitscript.com/forum/index.php?showtopic=103421&st=0&p=732733&#entry732733
  2. Funnily enough I am working on a artifact project in College and have been programming a USB Storage program that supports; [*] Different USB Drives (Identifies different drives using DriveGetSerial and backs up accordingly) [*] Full Backup [*] Incremental Backup [*] Backups you're data when working from you're USB Device as you're working (for example, you're working on a file called, 'Test.txt' which is located on your USB drive, - every time you save that document it will backup that file to the directory you specified earlier (in the configuration menu). If you want the source code then I'll PM you it, I'm not going to release it until my project has finished but it may help with the project you're currently under-taking. AwAke.
  3. I'm pretty sure this is the same structure PiroxBots use for their configuration, do correct me if I'm wrong however. Where is it you're going with this? I'm just generally intrigued.
  4. Oh my bad, I thought he ment exit the program via a hotkey, I guess I should of looked at it properly instead of the HotKeySet function he mentioned.
  5. GUISetAccelerators?
  6. I believe that still wont work, I may be wrong but when the application is minimized then there is no rendering taken place thus no pixels. I think its (impossible?) to detect pixels unless the window is active or being displayed.
  7. AwAke

    More C# Help!

    Ok thanks Authenticity, I can not thank you enough for your help. I'll clean up the code and see if that makes any difference. Thanks AwAke.
  8. AwAke

    More C# Help!

    Yeah that works :| When in its own project it works fine. However if I copy the 'USBSerialNumber.cs' file into my project. Add it as an existing class and call it, it gives me the error. O.O
  9. AwAke

    More C# Help!

    The drive that I'm requesting is given to me from a WndProc message and comes in the form per say as an example, G:\ The drives will always be USB Storage devices. Ill take a look at the attributes and the other topic is the exact same code I have in the class im calling yet I still get that error. Thanks for helping me out Authenticity, cheers Awake.
  10. AwAke

    More C# Help!

    Did you mean -> http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute.aspx
  11. AwAke

    More C# Help!

    Im not entirely sure about the exceptions, I'm guessing the, try & catch function? Ive never used it or looked into it but I guess I should. On regards to changing the trust settings. I went into the project settings -> security -> Enabled ClickOnce Security Settings -> Selected This is a full trust application Sorry if I have got the wrong end of the stick here, I dont understand much about this language. Just trying to get into a project and learn as I go. Thanks AwAk3e.
  12. AwAke

    More C# Help!

    Uhm now there is another problem, perhaps its with the class? Im calling the class like so; USBDriveSerialNumber.USBSerialNumber usb = new USBDriveSerialNumber.USBSerialNumber(); string serial = usb.getSerialNumberFromDriveLetter(path); MessageBox.Show(serial); But now there is an error in the class which is appearing at runtime? The error is with this bit of code; ManagementObjectSearcher searcher1 = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDiskToPartition"); foreach (ManagementObject dm in searcher1.Get()) And the error is: Context 0x33c3ff0 is disconnected. No proxy will be used to service the request on the COM component. This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the application is completely done with the RuntimeCallableWrappers that represent COM components that live inside them.
  13. AwAke

    More C# Help!

    Thanks for your reply Authenticity, the problem has been solved now. Thanks regardless!
  14. AwAke

    More C# Help!

    ... What would I do without you Manadar. Your always helping me and I can't thank you enough. Thanks alot I really appreciate it.
  15. AwAke

    More C# Help!

    Sorry for continiously coming here for help with C#, its the only forum I know which replies and with good advice. Im trying to achieve the same effect as the AutoIt function 'DriveGetSerial(path)' but in C#. So I read some forums and googled about and found this; http://downloads.cfdan.com/csharp/usbserialnumber.cs.txt So I added it as a class however VC 2008 returns six errors. The errors being: 1. The type or namespace name 'ManagementObject' could not be found (are you missing a using directive or an assembly reference?) 2. The type or namespace name 'ManagementObject' could not be found (are you missing a using directive or an assembly reference?) 3. The type or namespace name 'ManagementObjectSearcher' could not be found (are you missing a using directive or an assembly reference?) 4. The type or namespace name 'ManagementObjectSearcher' could not be found (are you missing a using directive or an assembly reference?) 5. The type or namespace name 'ManagementObjectSearcher' could not be found (are you missing a using directive or an assembly reference?) 6. The type or namespace name 'ManagementObjectSearcher' could not be found (are you missing a using directive or an assembly reference?) So its obvious that its something to do with the System.Management however it is in there as, 'Using System.Management'. I have no idea what the reason could be with it as I merely copied and pasted the entire class. Once again sorry for coming here for C# help, thanks in advance, AwAke.
×
×
  • Create New...