Technical Forum

Draw on desktop using visual c++

I am writing an opencv application to draw using laser beam using visual studio VC++ console application. I want to draw lines on desktop. I know that the drawing functions are available in GDI32.dll , but confused on how to integrate GDI32.dll with my vc code. can you suggest some good solution?



int main() {

/* hide console window */
ShowWindow(FindWindowA("ConsoleWindowClass", NULL), false);

/* Calling GetDC with argument 0 retrieves the desktop's DC */
HDC hDC_Desktop = GetDC(0);

/* Draw a simple blue rectangle on the desktop */
RECT rect = { 20, 20, 200, 200 };
HBRUSH blueBrush=CreateSolidBrush(RGB(0,0,255));
FillRect(hDC_Desktop, &rect, blueBrush);

return 0;

facing issue in loading a mp3 file in java getting could not get audio input stream from input file

I have the following code:

String fileName="D:/downloads/song.mp3";
File soundFile = new File(fileName);
AudioInputStream audioInputStream = null;
try {
audioInputStream = AudioSystem.getAudioInputStream(soundFile);
} catch (Exception ex) {

But the code raises the following exception:
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file
How can I solve this problem?


Sounds like you're missing an MP3 codec. See this thread for possible solutions. They mention a Java sound mailing list that might know more - You can read about threads and Android on the Official documentation Also, take a look at AsyncTask, that should help you a great lot.

The answers are to be found in the JavaSound tag info. page (a tag I added to the question). Look particularly to the sections on:
- Service Provider Interface
- Java Sound Capabilities
- MP3 decoding support

The first describes how the JavaSound system (and in fact many Java based services) are provided to apps. The 2nd should explain why your code fails for MP3. The 3rd will offer a way to add MP3 support to JavaSound.
BTW - what does any of this have to do with audio-recording ?

Android - bit confused on when to use threads & when to use services?

I am writing an android application to make server socket and receive messages from server when I write the same application using Thread, it works pretty well but I am unable to access UI elements in Thread whereas in case of services, startService method hangs on while(true){ socket.accept()}


You can read about threads and Android on the Official documentation of painless threading in android. Also, take a look at AsyncTask, that should help you a great lot.

how to create a scheduled task that runs when any user logins to the system

I want to launch an exe file of my product (C:\ClassConnect\class_server.cmd) on user login. I tried 2 solutions ( but nothing seems to work)
Solution 1 : ( Added Startup Shortcut ) It asks the user for UAC dialog, which obviously my users will not accept as its a spy app.
Solution 2 : ( Added batch to windows scheduler so that it runs for any user) It runs fine with the administrator account but fails for other users. Moreover I am not able to view scheduled tasks on other users Please help. ( I want the batch to run on startup for all users on my machine)


After struggling my head for so many days, I finally found the answer for running the program as admin
I wrote the following batch file to run one of my system program in admin mode without UAC Popup( it auto Enters the admin password )
I wrote a batch file run.bat with following content => it then executes a vb script which waits for 5 second and keys in the password.
================run.bat Start========================
set USER_NAME="administrator" set PASSWORD="test" set PROGRAM_NAME="C:\\ClassConnect\\class_student.bat" set "cm=cscript /B /nologo runas4.vbs %PASSWORD%" %cm% runas /profile /env /user:%USER_NAME% "%PROGRAM_NAME%"
================run.bat End========================
================runas4.vbs Start========================
Set objArgs = Wscript.Arguments password=objArgs(0) set WshShell = WScript.CreateObject("Wscript.Shell") WScript.Sleep 5000 bWindowFound = WshShell.AppActivate("ClassConnect_Teacher") WScript.Sleep 500 WshShell.SendKeys password WshShell.SendKeys "{ENTER}" set WshShell = nothing
================runas4.vbs End========================
The above script waits for 5 second and then enters the password for runas command thus I am able to run the script in admin mode.
If you are not sure about your access rights, download the isadmin.exe from internet.
if you do not have admin access on the system , activate the default disabled Administrator account. You can activate the account by using
net user administrator /active:yes
For resetting the default administrator password use: net user administrator *
You can read about threads and Android on the Official documentation Also, take a look at AsyncTask, that should help you a great lot.

Java 3d programming - Unable to access the changed position of 3d object?

We are working on a augmented reality project wherein the user will be able to virtually place 3d furniture objects on camera. We are able to place the 3d object (obj file) on capture image, java 3d allows me dynamically change or re-position the object using mouse and ViewingPlatform class, but I am not able to detect the new position of the object. Can you tell me on how to detect the Changed Angle or position of the 3d object?


public BranchGroup createSceneGraph(String file) {
objScale = new TransformGroup();
objTrans = new TransformGroup();
trans = new Transform3D();
BranchGroup objRoot = new BranchGroup();
Transform3D t3d = new Transform3D();
trans.setTranslation(new Vector3f(xloc, yloc, 0.0f));
int flags = ObjectFile.RESIZE;
flags |= ObjectFile.TRIANGULATE;
flags |= ObjectFile.STRIPIFY;
ObjectFile f = new ObjectFile(flags,
(float) (creaseAngle * Math.PI / 180.0));
System.out.println(60 * Math.PI / 180.0);
try {
loadscente = f.load(filename);
} catch (Exception e) {
bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 50.0);
System.out.println(bounds + "Bounds");
return objRoot;
public void addCompInPanel() {
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
c = new Canvas3D(config);
jPanel2.add("Center", c);
// Create a simple scene and attach it to the virtual universe
BranchGroup scene = createSceneGraph(filename);
u = new SimpleUniverse(c);
// add mouse behaviors to the ViewingPlatform
ViewingPlatform viewingPlatform = u.getViewingPlatform();
PlatformGeometry pg = new PlatformGeometry();
// Set up the ambient light
Color3f ambientColor = new+D4 Color3f(Color.RED);
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
// Set up the directional lights
Color3f light1Color = new Color3f(Color.RED);
Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
DirectionalLight light1 = new DirectionalLight(light1Color,
DirectionalLight light2 = new DirectionalLight(light2Color,

keyNavBeh = new KeyNavigatorBehavior(objTrans);
keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(),
System.out.println(keyNavBeh.getSchedulingBounds() + " keyNavBeh.getSchedulingBounds();");

// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.
OrbitBehavior orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ALL);

free software to create exe installer for java projects


Java Projects can be packaged into an installer or exe file nicely by using InstallJammer software. Its one of the simplest tool I have ever seen. Tool allows user to run exe in run as admin mode. Allows user to modify enviroment variables on client machine. There are many installers creators but the best one is InstallJammer.Take a look at InstallJammer Setup guide, that should help you a lot.