|
I have various Processes that are used in many of my programs. I want to put those Processes into "dills" so that I can load those dills when the User selects one in a program. This would illuminate the need to re-create the same processes in each program. The dills would need to contain it's own resources since they contain dialogs(the processes) and the program would not know in advance the resources. Is this possible? If so are there any tutorials on this subject using MFC?
Thanks in advance.
A C++ programming language novice, but striving to learn
|
|
|
|
|
|
I checked out some DILL articles. Nowhere is it explained whether a DILL can contain it's own resources. Can someone explain whether your DILL can contain Dialogs; and if so how can this be provided for linkage in a program.?
Since I don't know C#, or use the #include <windows.h> (because I use MFC exclusively), the articles you provided are useless to me. Thanks anyway.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: I checked out some DILL articles. Nowhere is it explained whether a DILL can contain it's own resources. Can someone explain whether your DILL can contain Dialogs; and if so how can this be provided for linkage in a program.?
Absolutely, you can add dialogs to a resource DLL. In fact a DLL doesn't even need to have code, it can contain resources only.
Creating a Resource-Only DLL[^]
Codeproject Resource-Only DLL[^]
Larry Mills Sr wrote: Since I don't know C#, or use the #include <windows.h> (because I use MFC exclusively), the articles you provided are useless to me. Thanks anyway.
I should have been more specific, I will try harder in the future. Let me see if I can find a C++ plugin framework that will work with MFC using the link I provided:
http://www.codeproject.com/info/search.aspx?artkw=plugin[^]
Oh wow... the first link goes to a cross-platform plugin implementation:
DynObj - C++ Cross Platform Plugin Objects[^]
The third link goes to a Win32 implementation and it looks like its using mostly ISO standards.
There are many other pages in my codeproject search, I am starting to believe that maybe you didn't even take the time to look.
Btw, you can use the 'Advanced filter' at the top to filter out C# and other language/platform articles.
Best Wishes,
-David Delaune
|
|
|
|
|
Any idea why this code doesn't compile?
#include "stdafx.h"
#include <bitset>
#include <iostream>
#include <ctime>
using namespace System;
int main(array<System::String ^> ^args)
{
const int N = 2000000;
clock_t cstart = clock();
bitset<N + 1> b;
int count = 0;
int i;
for (i = 2; i <= N; i++)
b.set(i);
i = 2;
while (i * i <= N)
{
if (b.test(i))
{
count++;
int k = 2 * i;
while (k <= N)
{
b.reset(k);
k += i;
}
}
i++;
}
while (i <= N)
{
if (b.test(i)) count++;
i++;
}
clock_t cend = clock();
double millis = 1000.0 * (cend - cstart) / CLOCKS_PER_SEC;
cout << count << " primes \n" << millis << " milliseconds\n";
return 0;
}
Errors:
Error 4 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 19 SieveOfErathostenes
Error 5 error C2228: left of '.set' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 19 SieveOfErathostenes
Error 6 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 24 SieveOfErathostenes
Error 7 error C2228: left of '.test' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 24 SieveOfErathostenes
Error 8 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 30 SieveOfErathostenes
Error 9 error C2228: left of '.reset' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 30 SieveOfErathostenes
Error 10 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 39 SieveOfErathostenes
Error 11 error C2228: left of '.test' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 39 SieveOfErathostenes
Error 12 error C2065: 'cout' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 46 SieveOfErathostenes
NOTE:
1. Core Java Vol I 8th Ed. Pg. 713 (727)
Jon
|
|
|
|
|
Probably you get errors because are in the wrong forum (better luck here [^], maybe).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The first error I get is this:
a.cpp(14) : error C2065: 'bitset' : undeclared identifier
This is because you use bitset without prefixing it with std:: , which is the namespace it lives in. Similarly, cout needs a std:: prefix, because that's where it lives.
[edit]Fix those two, and your code compiles fine. It runs as well.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Resolved that by including 'using namespace std;'. Now it reads:
C1010 - unexpected eof. Says it needs a header file, but I "forgot" what to include. Afiak the header file includes:
#pragma once
...
...and the headers of the methods used in my case...
int main...
However, it's strange that the default template created by visual studio with a main method did not require a .header file.
#include <bitset>
#include <iostream>
#include <ctime>
using namespace System;
using namespace std;
int main(array<System::String ^> ^args)
{
const int N = 2000000;
clock_t cstart = clock();
std::bitset<N + 1> b;
int count = 0;
int i;
for (i = 2; i <= N; i++)
b.set(i);
i = 2;
while (i * i <= N)
{
if (b.test(i))
{
count++;
int k = 2 * i;
while (k <= N)
{
b.reset(k);
k += i;
}
}
i++;
}
while (i <= N)
{
if (b.test(i)) count++;
i++;
}
clock_t cend = clock();
double millis = 1000.0 * (cend - cstart) / CLOCKS_PER_SEC;
cout << count << " primes \n" << millis << " milliseconds\n";
return 0;
}
Sieve.h
#pragma once
#include <iostream>
int main(array<System::String ^> ^args);
Related links:
C++ Header files[^]
Jon
|
|
|
|
|
jon_80 wrote: C1010 - unexpected eof. Says it needs a header file, but I "forgot" what to include. Afiak the header file includes:
stdafx.h - it's probably got pre-compiled headers enabled if it's a VS project.
You don't need the Sieve.h file.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
To be true, I have never used dllimport in my code while using a module. What's the actual use of it? No matter we use it or not, we are able to access the exported symbol right?
----------------------------
286? WOWW!
|
|
|
|
|
Hi 8086,
Raymond Chen wrote a series about imports and exports[^] and its implementation history. Its an excellent read and I think you will enjoy it.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks for the Pointer Randor!
----------------------------
286? WOWW!
|
|
|
|
|
Hi Randor,
Just found this in MSDN :
Using __declspec(dllimport) is optional on function declarations, but the compiler produces more efficient code if you use this keyword. However, you must use __declspec(dllimport) for the importing executable to access the DLL's public data symbols and objects. Note that the users of your DLL still need to link with an import library.
Thanks for your reply.
----------------------------
286? WOWW!
|
|
|
|
|
Thats a fair but short description of dllimport. I apologize for sending you off to do your own research. Its just that sometimes I feel like I am answering the same questions over and over. Here is a thread from 2008 where dllimport was discussed. You can be surprised with what a well-formed codeproject search will find.
http://www.codeproject.com/Messages/2431922/Re-import-library.aspx[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi
We know that, WinMain is buried in the MFC Framework. OK but how can Windows call it?
I opened MFC project in VC++ and tried to find out how it imports the dll(Mfc90ud.dll) and functions in that dll. But i couldn't find it. I also disassembled the mfc90ud.dll but there is no function like WinMain in exported function list. Function names are just numbers.
So, I have 2 questions.
1-) How does VS knows that Mfc90ud.dll must be imported and Windows know that it must call a function in a dll that is imported by EXE?
2-) If i import a dll and although i do not use one of the imported function in that dll, OS can still call that function? Or OS can only call imported dll functions which are used by exe?? If the function doesn't import by exe, it is never be called?
Thanks...
|
|
|
|
|
Normally WinMain is not exported in DLLs. What happens is that WinMain is not called directly by the loader (and main(), likewise). The code that calls it, is a bootloading code, which is addressed by a DLL/EXE entry point. This code does all the initialization and at the end of it calls into WinMain/main(), the address of which is known during compilation.
|
|
|
|
|
sawerr wrote: We know that, WinMain is buried in the MFC Framework. OK but how can Windows call it?
The linker tries to locate and execute an entry-point in your code, which may be dependent on the type of application you are building: WinMain (or wWinMain if built for Unicode) or main (or wmain if built for Unicode). The former is for windowed applications and the latter is for console applications. If no entry point is defined in your application, you will get an undeclared identifier from the linker.
sawerr wrote: If i import a dll and although i do not use one of the imported function in that dll, OS can still call that function? Or OS can only call imported dll functions which are used by exe?? If the function doesn't import by exe, it is never be called?
That depends. There are DLLs that you may not reference directly from your code but Windows will load and execute code from those libraries. This is because some of the functions in those libraries may be indirectly referenced. Other than that, only what you are calling from your code will be loaded or executed.
The fact is that this is a larger topic to be discussed in a thread like this. If you really are wanting to read up on how programs work and how Windows work, I'll recommend the book by Jeffrey Richter and Christopher Nasarre (every edition of the book gets a new name. The latest one is called Windows Via C/C++).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Thanks for answers.
I know that loader must fill IAT with imported functions. If I don't import a function so function can't be placed in IAT. So even this function is exported from dll, Windows can't call it. But i'm not sure about that so i started that thread.
I understand that winmain(or whatever) isn't added to import section by exe, this is special case for entry point. A function can be called without adding IAT is entry point. This is valid just for entry point. Is that right?
|
|
|
|
|
Exported functions can be called (or, rather, located and addressed) from the outside - so, whenever you need a function to be addressable from the outside you (or compiler/linker) make it exported. This is the only rule
|
|
|
|
|
Hii
In my application , wanna copy all files from one partition to another partition.
First I copied a file that I taken default and copied to another partition.
The above operation is done by using the control code "FSCTL_GET_RETRIEVAL_POINTERS".
The clusters used are read and wrote into destination volume using readfile() and writefile() windows functions.
Now I gotta copy all files.....
So how to proceed ....??
Thanking you.
|
|
|
|
|
Hi krish,
krish_kumar wrote: So how to proceed ....??
Why are you using DeviceIoControl to copy files? Are you doing this from usermode or ring0/kernelmode?
Best Wishes,
-David Delaune
|
|
|
|
|
|
Well, if you're in user-mode, just iterate through *all* the files in the partition, read them into memory and write them into the other partition. Not tricky.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
krish_kumar wrote: I use it in user mode.
Yes, I remember you now. Your the guy who has been asking this question in all of the kernelmode driver forums for the last few weeks.
Doron Holan over at Microsoft and many other highly respected engineers have given you the same advice. You should just copy the partition from usermode using the standard functions. Your not going to get much benefit from using kernel functions from usermode.
Now with that being said, what exactly are you having problems with? You state in this post[^]
I used the "FSCTL_GET_VOLUME_BITMAP" to get the cluster usage details.And I'm
getting the used and free cluster counts correctly.And the cluster number I got
is continuous.This makes problem for me. I wanna copy the used clusters to a
different partition.
Mark Roddy over at Microsoft wrote an article about finding and copying disk sectors. Have you read it?
Adventures in Luserland: Finding Disk Sectors Associated with File Records.[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hii
First I started with kernel mode and after that as per replies from Mr.Doron Holan Presently I do my application in user mode only.
In Mark Roddy's article ,takes each file handle and it's appropriate clusters.
So here in my program I took a sample file and get it's corrresponding cluster
details using "FSCTL_GET_RETRIEVAL_POINTERS" along with DeviceIoControl and copied it into another partition.
And this successfully copied the source file .
Like this I wanna get all files.So it may take much more time..?
How to get all file one by one.?
And I tried one more way using "FSCTL_GET_VOLUME_BITMAP"along with DeviceIoControl.In this case I take the
whole volume as handle to createfile() and find out the used cluster only;and simply copied them to another partition.After that I can't open some folders in the destination partition...
Here I'm not reinitializing links among them...and have to reallocate MFT..?
Thanking you...
|
|
|
|