I made a simple app to turn off a monitor. The entire program consists of just this:
monoff.cpp

#include "windows.h"
#define MON_OFF 0x2
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,  LPSTR lpCmdLine, int nCmdShow)
{
	SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, MON_OFF);
	return 0;
}

For some reason it still wont run without msvcr100.dll!

how do I compile this that it will run with the standard dlls that windows ships with?

thanks for any help

Recommended Answers

All 6 Replies

Create a console project, and use
#define WIN32_LEAN_AND_MEAN

kewl, thanks.

I just found a few links on this topic:

http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx

.. says you should compile with static options /MT or /MTd.
I read also that if you don't use .NET Framework 4.0, setting the target framework to an older version might also change this dependency.

I knew about the /MT thing. But I have to try that win32_lean_and_mean thing. I just need to find a computer somewhere that I know hasn't already had the vc++ redistributable installed on it already so I know for sure. Also, I downloaded a version of of "Pelles C", so I'm going to try compiling it as regular old C too and see what happens.

edit: using the /MT in pelles C gives me a small 18kb file instead of the 32.5kb that I get with VC++ 2010. If I choose the single threaded option in pelles, the file compiles to 8.5kb

#define WIN32_LEAN_AND_MEAN 
#include "windows.h"
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
	return 0;
}

>>I just need to find a computer somewhere that I know hasn't already had the vc++ redistributable installed on it already

That should be quite easy -- just do a fresh install of the Windows operating system.

I know that..lol
I only have one computer though. I do start school in October though...
I'm sure they have got some old junker computers hanging around.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.