Re: exe error, works on some pcs but doesnt on others

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You are a victim of the "improved" error reporting. The message is stupid, and was
designed by someone who never once, in his entire life, EVER, wrote a program, as far as I
can tell.

The message can occur if you do not use an installer script but try to copy the .exe file
to the computer in question. If the computer happens to have the right DLLs, it works,
and if it doesn't, you get this stupid message designed by irresponsible people. (It also
shows there is no adult supervision at Microsoft; no intelligent human being would have
allowed this nonsensical message to pass a design review!). Of course, it would have been
nice, as in earlier versions of the OS, to have it come out and say "Unable to load
XXXXX.dll", which is what it is hiding. Then you would KNOW what is wrong, instead of
trying to guess!

Make sure you have a .msi file to install it; create this using the install project
wizard. Unfortunately, the "wizard" is crippled (another piece of irresponsible design)
and doesn't actually create a usable installation script; I have to fight it each time to
get everything right. Sigh.

It is not a compiler error; it is almost certainly an install error.
joe

On Sun, 6 Sep 2009 23:45:31 -0700 (PDT), Aegis Delacour <eloquent1@xxxxxxxxx> wrote:

Hi..i have a problem where my code when compiled works only on some
PCs for a reason i dont really know. it gives me this error.

this application has failed to start because the application
configuration is incorrect. reinstalling the application may fix the
problem..

here is my code, if it is a compiler error on my part..could someone
compile it and send me the exe please
as i dont have access to visual studio anymore and i need to get this
fixed.

thank you

#include <windows.h>
#include <stdio.h>
#include <fstream>
#include <GdiPlus.h>

using namespace Gdiplus;
using namespace std;

int GetEncoderClsid(WCHAR *format, CLSID *pClsid)
{
unsigned int num = 0, size = 0;
GetImageEncodersSize(&num, &size);
if(size == 0) return -1;
ImageCodecInfo *pImageCodecInfo = (ImageCodecInfo *)(malloc(size));
if(pImageCodecInfo == NULL) return -1;
GetImageEncoders(num, size, pImageCodecInfo);
for(unsigned int j = 0; j < num; ++j){
if(wcscmp(pImageCodecInfo[j].MimeType, format) == 0){
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j;
}
}
free(pImageCodecInfo);
return -1;
}

int GetScreeny(LPWSTR lpszFilename, ULONG uQuality)
{
ULONG_PTR gdiplusToken;
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

HDC hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
HDC hdcCapture = CreateCompatibleDC(hdcScreen);
int nWidth = GetDeviceCaps(hdcScreen, HORZRES),
nHeight = GetDeviceCaps(hdcScreen, VERTRES),
nBPP = GetDeviceCaps(hdcScreen, BITSPIXEL);

LPBYTE lpCapture;
BITMAPINFO bmiCapture = { {
sizeof(BITMAPINFOHEADER), nWidth, -nHeight, 1, nBPP, BI_RGB, 0, 0,
0, 0, 0,
} };
HBITMAP hbmCapture = CreateDIBSection(hdcScreen, &bmiCapture,
DIB_PAL_COLORS, (LPVOID *)&lpCapture, NULL, 0);
if(!hbmCapture){
DeleteDC(hdcCapture);
DeleteDC(hdcScreen);
GdiplusShutdown(gdiplusToken);
return 1;
}

int nCapture = SaveDC(hdcCapture);
SelectObject(hdcCapture, hbmCapture);
BitBlt(hdcCapture, 0, 0, nWidth, nHeight, hdcScreen, 0, 0, SRCCOPY);
RestoreDC(hdcCapture, nCapture);
DeleteDC(hdcCapture);
DeleteDC(hdcScreen);

CLSID imageCLSID;
Bitmap *pScreenShot = new Bitmap(hbmCapture, (HPALETTE)NULL);
EncoderParameters encoderParams;
encoderParams.Count = 1;
encoderParams.Parameter[0].NumberOfValues = 1;
encoderParams.Parameter[0].Guid = EncoderQuality;
encoderParams.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParams.Parameter[0].Value = &uQuality;
GetEncoderClsid(L"image/jpeg", &imageCLSID);
int result = (pScreenShot->Save(lpszFilename, &imageCLSID,
&encoderParams) == Ok);
delete pScreenShot;
DeleteObject(hbmCapture);
GdiplusShutdown(gdiplusToken);
return result;
}

int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR
lpCmdLine, int nShowCmd)
{
int status;
ifstream ifile;

ifile.open("screeny1.jpg");
if( ifile.is_open() == false)
{
status = GetScreeny(L"screeny1.jpg", 75); //get the screenshot
}
else //1 exist
{
ifile.close();
ifile.clear();
ifile.open("screeny2.jpg");
if( ifile.is_open() == false)
{
status = rename("screeny1.jpg", "screeny2.jpg");
status = GetScreeny(L"screeny1.jpg", 75);
}
else //2 exist
{
ifile.close();
ifile.clear();
ifile.open("screeny3.jpg");
if( ifile.is_open() == false)
{
status = rename("screeny2.jpg", "screeny3.jpg");
status = remove("screeny2.jpg");
status = rename("screeny1.jpg", "screeny2.jpg");
status = GetScreeny(L"screeny1.jpg", 75);
}
else //3 exist
{
ifile.close();
ifile.clear();
ifile.open("screeny4.jpg");
if( ifile.is_open() == false)
{
status = rename("screeny3.jpg", "screeny4.jpg");
status = remove("screeny3.jpg");
status = rename("screeny2.jpg", "screeny3.jpg");
status = remove("screeny2.jpg");
status = rename("screeny1.jpg", "screeny2.jpg");
status = GetScreeny(L"screeny1.jpg", 75);
}
else //4 exist, meaning 5 must be deleted no matter what
{
ifile.close();
ifile.clear();
status = remove("screeny5.jpg");
status = rename("screeny4.jpg", "screeny5.jpg");
status = remove("screeny4.jpg");
status = rename("screeny3.jpg", "screeny4.jpg");
status = remove("screeny3.jpg");
status = rename("screeny2.jpg", "screeny3.jpg");
status = remove("screeny2.jpg");
status = rename("screeny1.jpg", "screeny2.jpg");
status = GetScreeny(L"screeny1.jpg", 75);
}
}
}
}

// return 0; //return 0 to Windows
}
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: exe error, works on some pcs but doesnt on others
    ... Most likely, what it really means is that you did not install all the DLLs upon which your application depends, or that a manifest was not found in the file for the CRT. ... int GetScreeny ... GdiplusStartupInput gdiplusStartupInput; ... EncoderParameters encoderParams; ...
    (microsoft.public.vc.mfc)
  • Install Curses for Bastille Install
    ... This is on a brand new install of fedora core 1. ... function 'nocbreak' returns int ... CursesFun.c:1279: warning: initialization from incompatible pointer type ...
    (perl.beginners)
  • Re: More CChildFrame questions
    ... DisplayInfo info; ... Note that if you "know UML" then why didn't UML tell you that your design was bad? ...
    (microsoft.public.vc.mfc)
  • DBD::InterBase (Firebird 1.5.4) compilation troubles on 64 bit Ubuntu 7.10
    ... Ubuntu 7.10 by usage of CPAN ... Running install for module DBD::InterBase ... dbdimp.c:1459: warning: format '%04d' expects type 'int', ... when searching for -lfbclient ...
    (perl.dbi.users)
  • Re: Test Driven Development Sample
    ... "Isaac Gouy" wrote in message ... > scores for a possibly incomplete sequence of valid throws - update the ... "how" aspect of the design. ... int FrameNum; ...
    (comp.object)