View Single Post
Old 09-05-2007, 04:11 PM   #7 (permalink)
machx0r
 
Join Date: Sep 2007
Posts: 12
Thanks: 3
Thanked 25 Times in 1 Post
machx0r is on a distinguished road
Default

Quote:
Originally Posted by qwho View Post
Cool, I was just playing with your source lol. Very nice. Any chance you found a way to use it with VB? My c++ skills are lacking.
Thanks. That was my first Visual C++ and C# application. Some of the structures needed for the DeviceIoControl native function were not easily reproduced in VB or C# so I built the C++ DLL to wrap the native functions. If you want to use the camera flash in a VB or C# application do this:
  • Right click your project
  • Select Add -> Existing Item
  • Browse to "MotoQCameraFlash.dll" from my source and add it
  • Under the File Properties for "MotoQCameraFlash.dll" set the "Build Action" to "Content" and the "Copy to Output Directory" to "Copy Always"
  • Add "Imports System.Runtime.InteropServices" to your code or References
  • Setup DllImport calls to add CloseCameraHandle(), DisableFlash(), EnableFlash(), and OpenCameraHandle() from my DLL to your VB project.
  • To enable the flash call OpenCameraHandle() then EnableFlash()
  • To disable the flash call DisableFlash() then CloseCameraHandle()
It's easier for me to explain through code (and probably easier for you to understand) so here is a quick example VB project: http://www.charltonfamily.net/downloads/misc/For%20qwho.zip

In my Moto Q Flashlight I wrapped these functions into the CameraFlash class (CameraFlash.cs) to provide better control over when to open a handle and track the state of the flash.

A trick you might find handy for converting code from C# to VB or vice versa is to decompile the exe with Reflector (http://www.aisto.com/roeder/dotnet/) and then choose your preferred code language in the drop down. This has helped me immensly to transition from VB to C#


Quote:
Originally Posted by qwho View Post
Does the finder work? Have you tried it?

How does it manage to stay open 24/7? Is it always accessing the message intercept?
Yes it works well. The application does not run constantly. When you exit the application through MenuItem1_Click a new MessageInterceptor class is created. The MessageInterceptor.EnableApplicationLauncher() sub creates a rule (not sure where, registry probably) that launches the application if the MessageCondition specified is met.

Quote:
Originally Posted by qwho View Post
Sorry for all the questions lol.
No worries I'm happy to help.
__________________
-- Cory

www.charltonfamily.net
machx0r is offline   Reply With Quote
 
Integrated by BBpixel Team 2008 :: jvbPlugin R1015.37x.1