Re: Dont want Intermediate language



"Neo" <neoscandal@xxxxxxxxx> wrote in message
news:Xns9781E178DB15ANeo@xxxxxxxxxxxx
"Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx> wrote in
news:#UquMQ5QGHA.1728@xxxxxxxxxxxxxxxxxxxx:

Neo wrote:
I recently wrote win32 C++ code for a SFX creator/extractor exe..
which compiled with Bloodshed Devc++ churns out 26 kb under full
optimisations.

I have VC.Net 2005 'express edition' installed. Can i in anyway
complie my code using this.. I want it to be converted straight to
exe and not the 'intermediate language' used by .net.

Sure, just compile it as a Win32 application and it won't be managed
code. You'll probably have to download and install the Platform SDK
in order to build it.

-cd




It does not seem to support .rc files. I want my sfx exe to be as
small as possible.


It absolutely does support .rc files. There is no WYSIWYG resource editor,
so you have to either type out the .rc files manually or use some third
party tool to generate them, but once the .rc file has been made, VC++
Express will certainly compile it.

The following successfully compiles for me using VC++ Express (beware of
word wrapping in the following lines; in particular, string literals should
be on a single line). I have just taken your code and made minimal changes.
There is probably other stuff relating to language choice and the like that
should go in the .rc file. For your undefined functions, I just added empty
brackets or an appropriate return statement.

Incidentally, you should not be calling ExitProcess in the event of failure
since that stops C++ code from cleaning itself up properly at exit. Just let
WinMain finish by running out of code lines to execute.


//////////////////////////////////////////////
// resource.h
//////////////////////////////////////////////

#define IDD_SFX 1000
#define IDC_F1 1001
#define IDC_F2 1005
#define IDC_BTN1 1002
#define IDC_BTN2 1006
#define IDC_STC1 1003
#define IDC_STC2 1004

////////////////////////////////////////////////////////
// main.rc
/////////////////////////////////////////////////////
#include "resource.h"

IDD_SFX DIALOGEX 5,5,168,85
CAPTION "SFX example"
FONT 8,"Courier New",400,0,0
STYLE 0x10C80800
EXSTYLE 0x00000000
BEGIN
CONTROL "",IDC_F1,"Edit",0x50010001,60,5,103,14,0x00000200
CONTROL "",IDC_F2,"Edit",0x50010001,60,24,103,14,0x00000200
CONTROL "Create SFX with data file 1 to file
2",IDC_BTN1,"Button",0x50010001,1,41,163,17,0x00000000
CONTROL "Extract data to file
1",IDC_BTN2,"Button",0x50010000,1,63,163,17,0x00000000
CONTROL "File 1 :",IDC_STC1,"Static",0x50000201,5,8,48,7,0x00000000
CONTROL "File 2 :",IDC_STC2,"Static",0x50000201,5,25,50,10,0x00000000
END

///////////////////////////////////////////////////////////////
// main.cpp
//////////////////////////////////////////////////////////////
#include <windows.h>
#include "resource.h"

#define EXE_SIZE 26624
#define BLK_SIZE 20480

BOOL CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
void ShowError(const char*);
void showNumMsg(DWORD num);
bool create_sfx(const char*, const char*);
bool extract_data(const char*);
DWORD fSize(HANDLE fp);
bool sfxHasAppendedData();

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
if(sfxHasAppendedData())
MessageBox(NULL, "This SFX has data ;)",NULL,NULL);

if(DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_SFX),
NULL, WndProc,(LPARAM)NULL)==-1)
MessageBox(NULL,"Error Loading",NULL,MB_ICONERROR);
else
ExitProcess(0);
}

BOOL CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch (message)
{
case WM_COMMAND :
if (HIWORD (wParam) == BN_CLICKED)
{
UINT iBufSize;
char szTextBox1[20], szTextBox2[20];
GetDlgItemText(hwnd,IDC_F1,szTextBox1,20);
GetDlgItemText(hwnd,IDC_F2,szTextBox2,20);

if (LOWORD (wParam) == IDC_BTN1 )
{
if(!create_sfx(szTextBox1, szTextBox2))
ShowError("SFX creation Error");
else
ShowError("SFX creation Successful");
}
if (LOWORD (wParam) == IDC_BTN2 )
{
if (!sfxHasAppendedData())
{
MessageBox(NULL, "Sorry, no appended data :(","no cant
do",NULL);
return TRUE;
}
if(extract_data(szTextBox1)== false)
ShowError("Data extraction Error");
else
ShowError("Data extraction Successful");
}
}
return TRUE ;
case WM_CLOSE :
EndDialog(hwnd,0) ;
return TRUE ;
}
return FALSE ;
}


void ShowError(const char *pos)
{}
bool create_sfx(const char* file, const char *toFile)
{return true;}
bool extract_data(const char *toFile)
{return true;}
void showNumMsg(DWORD num)
{}
DWORD fSize(HANDLE fp)
{ return DWORD();}
bool sfxHasAppendedData()
{return true;}


--
John Carson


.


Loading