|
Hi,
Can you please let me know how to do the following?
I have a console exe that does something. I call this exe from Dialog based MFC app. I want to add this console exe into MFC resource and then use it in the MFC app. Can this be done? My idea here is to have only one exe instead of two .
Thanks in advance
Vikas
|
|
|
|
|
|
don't reply to some when
1) you didn't read his question
2) you didn't understand his question
3) you don't know the topic
4) you don't know how to solve it
you post is damn useless
|
|
|
|
|
He wants to insert exe in his resource not run an exe file.
|
|
|
|
|
Add it as a custom resource, let's say "BIN" resource. Then use FindResource and LoadResource to access it. I guess you plan to run it, then dump it as a temp file and run it.
I have used similar technique with driver and it works like a charm.
God bless,
Ernest Laurentin
|
|
|
|
|
|
|
It's not supposed to.
If it is showing a hidden window, then it must be true.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have an app which will have a lot of controls on it, and will probably make it a dialog based app for easy layout of these controls. Are there any limitations/problems of making it dialog-based instead of normal window-based ?
What are the rules on when an app should be dialog-based and when it should be a normal window-based ?
Can a dialog based app have a menu bar and toolbar ?
|
|
|
|
|
Defenestration wrote: What are the rules on when an app should be dialog-based and when it should be a normal window-based ?
I don't know about the rules, but it can be a lot easier to layout many controls
on a dialog resource than it is to create them manually at runtime for a window.
Defenestration wrote: Can a dialog based app have a menu bar and toolbar ?
Yes The menu you can add to the dialog resource.
For toolbars, you can do it manually... for one example, see
DLGCBR32 Sample: Demonstrates Adding a Status Bar and Toolbar to Dialog Boxes[^]
If you use MFC, IMO the easiest method is to use a frame window for the main window and use
a modeless dialog as the client window (or you could even use a CFormView). MFC handles window
decorations like toolbars and status bars and does the layout of the client window - makes it real
easy to code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Defenestration wrote: I have an app which will have a lot of controls on it, and will probably make it a dialog based app for easy layout of these controls
For that kind of app, I prefer to use a SDI application where the view is a CFormView. The CFormView has an associated dialog resoruce - lay out your controls on that as you would for a dialog. The rest of the framework handles the menus and toolbars and such for you so you get a nice merging of dialog capabilities and "normal" window-based capabilities.
Judy
|
|
|
|
|
I'm still learning C and C++. I found this magical bit of code that will give the number of elements in an array without knowing it's type. Can anyone explain this in terms mere mortals can understand?
In WinNT.h, around lines 939:
extern "C++"
template <typename t,="" size_t="" n=""><br />
char (*RtlpNumberOf( UNALIGNED T (&)[N] ))[N];<br />
<br />
#define RTL_NUMBER_OF_V2(A) (sizeof(*RtlpNumberOf(A)))</typename>
|
|
|
|
|
It works because it knows the size of T at compile time.
The compiler generates a function at compile time which does:
#define RTL_NUMBER_OF_V1(A) (sizeof(A)/sizeof((A)[0]))
So if you call the RTL_NUMBER_OF() macro on objects of several different types, it generates a seperate function for each type.
Best Wishes,
-David Delaune
|
|
|
|
|
That's the way I would expect it to work, but I'm sure not seing that in that uncompilable code
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Never mind. I missed this...
Glenn Sandoval wrote: In WinNT.h, around lines 939:
Which led me to the missing code
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Glenn Sandoval wrote: Can anyone explain this in terms mere mortals can understand?
i think the following is too descriptive for mere mortals.
Glenn Sandoval wrote: I found this magical bit of code that will give the number of elements in an array without knowing it's type.
I can see three magics. 1 ) one taking advantage of sizeof(char) as 1, 2)taking advantage of const parameter in template declaration to deduce the size of array.
3) sizeof() operator only bothers type, it won't execute function
Glenn Sandoval wrote:
template <typename T, size_t N>
char (*RtlpNumberOf( UNALIGNED T (&)[N] ))[N];
#define RTL_NUMBER_OF_V2(A) (sizeof(*RtlpNumberOf(A)))
1) use of sizeof(char)
(*RtlpNumberOf(A)) effectively has the return type as the charater array type with the equal number of elements that of the Array passed, since sizeof (char) is 1, the sizeof (character array) will be the number of elements.
ie; if you pass <array of anytype>[128], then return type of RtlpNumberOf is char(*)[128], so sizeof(* char(*)[128]) = sizeof(char[128]) = 128 * sizeof(char) = 128
char (*function())[10]; function returning pointer to character array(as function cannot return array so pointer to array)
sizeof(*function()) = sizeof(*char(*)[10]) = sizeof(char[10]) = 10 * sizeof(char) = 10;
// note sizeof operator uses dereferenced return type. (*function())
2) use of const parameter in template
template <size_t N>
void func(char (&arr)[N]);
here the constant parameter N is deduced to number of element of array.
so char cArray[128]; func(cArray) will deduce N as 128;
putting it togetter,
template <typename T, size_t N>
char (*func(T (& )[N]))[N]
func has return type char (*)[N] which sizeof() operator considers.
3) use of sizeof() operator won't execute function.
So definition of function is not needed. at the point of template instantiation, N is deduced to the number of element of array, function is not executed, returns the number of elements.
advantage
advantage of this over sizeof(array)/sizeof(array[0]) is,
1) unnamed struct cannot be used.
2) pointer which may not be an array cannot be used.
modified on Friday, March 7, 2008 10:11 AM
|
|
|
|
|
Rajkumar R wrote: advantage of this over sizeof(array)/sizeof(array[0]) is,
1) unnamed struct cannot be used.
2) pointer which may not be an array cannot be used.
Thanks, that was going to be my next question.
I appreciate all the great responses. I think I understand now.
|
|
|
|
|
I am trying to invoke a Win32 DLL from the Windows Installer to perform certain custom actions.
For this purpose I have exposed 1 API
MY_DLL_API UINT MyCustomActionLaunch(MSIHANDLE hMsiModule)
{
MessageBoxW (NULL, L"MyCustomAction launch", L"MyCustomAction", MB_OK);
WCHAR msg [500] = {0};
WCHAR vbuff [1024] = {0};
DWORD vlen = 1024;
UINT gp = MsiGetPropertyW(hMsiModule, L"ProgramFilesFolder", vbuff, &vlen);
if(gp == ERROR_SUCCESS )
{
if (wcslen(vbuff) <= 0)
{
<big> MessageBoxW(NULL , L"Zero Bytes",L"MyCustomAction" , MB_OK);</big> }
MessageBoxW(NULL, vbuff, L"MyCustomAction", MB_OK);
} else
{
MessageBoxW (NULL, L"Failure", L"MyCustomAction", MB_OK);
}
return -1;
}
I find that no bytes are being copied, where I am querying for a standard property .
This DLL is being developed in VC6.
Does anyone see anything wrong here ?
Engineering is the effort !
|
|
|
|
|
Hello,
i'm trying to code a small encryption application, which encrypts files with different algorithms. i'm using crypto++ lib for the encryption part, and qt for the gui part. now after struggling with the encryption for a while, i found an example via google that i'm using now to encrypt files. its like this:
const char* CrypThread::EncryptAes(const char* inputFileName, const char* outputFileName, const char* password)<br />
{<br />
byte pass[AES::BLOCKSIZE]; <br />
byte iv[16]; <br />
byte true_iv[16]; <br />
<br />
AutoSeededRandomPool rng;<br />
<br />
try <br />
{ <br />
StringSource(password, true, new HashFilter(*(new SHA256), new ArraySink(pass, AES::BLOCKSIZE)));<br />
<br />
rng.GenerateBlock(iv, 16);<br />
memset(true_iv, 0, 16);<br />
<br />
AES::Encryption aesEncryption(pass, CryptoPP::AES::DEFAULT_KEYLENGTH);<br />
CFB_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption, iv, 8);<br />
<br />
StreamTransformationFilter *encryptor;<br />
<br />
encryptor = new StreamTransformationFilter(cbcEncryption, new FileSink(outputFileName));<br />
encryptor->Put(iv, 16);<br />
<br />
FileSource(inputFileName, true, encryptor);<br />
}<br />
catch(CryptoPP::Exception &e)<br />
{<br />
return e.what();<br />
}<br />
<br />
return 0;<br />
}
While the encryption seems to work (i admit that i dont really know what i'm doing..), i was wondering if there is any way to monitor encryption progress. i want to implement a progress bar in the program, so you can see how far your 2gb file is encrypted already. my current idea is to watch the destination file with a QFileSystemWatcher, and set the current size of the destination file as progress. this would probably work, however the file size of the destination file stays 0 until the encryption is finished, even if the file is quite large.
is there any way to have crypto++ stream the encryption right to the hdd, so the file size grows?
if not, maybe someone has an idea of how to implement a progress-monitor function? in the application, the main thread runs the gui stuff, whereas the encryption is done in a separate thread.
also, since i'm still having issues with crypto++, anyone knows a site thats showing examples with file encryption?
tia for any help
|
|
|
|
|
Hi All,
I have an ActiveX control. And the event map is defined in the control's implementation (.CPP) file.
Say the event map has a function
EVENT_CUSTOM("SomeEvent", FireSomeEvent, VTS_BOOL)
defined in it...
Now I can very easily call the function 'FireSomeEvent' from the control's implementation cpp file.
Can I call 'FireSomeEvent' from some other cpp file....means some other's class's code ??
If yes then how??
Urgent help needed...
Thanks and Regards,
AbbyIndian
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
As long you have a reference of this class and the member is public...you should.
God bless,
Ernest Laurentin
|
|
|
|
|
Is it possible to place an activex control on a dialog box of a DLL. When I try to do this the dailog box does not show up. The activex shows on on the dialog box of an exe just fine.
I am assuming that you need to do something different when working with DLLs.
Thanks,
Deelip Menezes
|
|
|
|
|
Make sure you call CoInitialize(NULL) in your app. It doesn't matter it's inside of a DLL.
God bless,
Ernest Laurentin
|
|
|
|
|
Just tried that. Did not work. I put CoInitialize(NULL) in the CWinApp constructors of the DLL as well as the EXE. Am I doing something wrong?
I am usign VC 6.0 and when making the AppWizard generated DLL I checked the Automation box. So it should already be set up to run ActiveX controls.
Any ideas?
Deelip Menezes
|
|
|
|
|
Hi,
I have a Windows App/process that consists of one exe and a bunch of DLL's
In of othe DLL's I allocate a object via the "new" operator and save the pointer to it
in a sturcture which is part of another DLL
later on a exported function in my DLL gets invoked from one of the DLL's in the app
only to find this pointer has a value of NULL
My question is.. Is storage for an object allocated via the "new" operator gone once the code in the DLL finishes executing even though the DLL is in core
If so is it possible to allocate storage for an object and have it remain in storage for the life of the DLL
|
|
|
|
|