|
You need a good book to know about DLLs,
amar_shinde wrote:
Now if 10 differenct clients use the same DLL, is it that there will be 10 copies of the DLL with the 10 clients
no 10 copies of the dll is not made, only one is made, but loading an address space into a process is bit tricky issue, it involves the knowledge of LDT (local discriptor table)
amar_shinde wrote:
Also, DLLCanUnloadNow() checks if there are any clients attached to this DLL.
This check is done my the OS when each clients start unloading the DLL, or in some case in a fixed interval or time.
Generally a global variable called as reference count is incremented or decremented depending upon loading or unloading, When this reference count is zero the dll code has the option to unload itself from the memory by returing appropriate value.
Still Alive!!!
Thank you God.
|
|
|
|
|
You might have been correct in 16-bit Windows; in 32- and 64-bit Windows, you should treat them as separate copies. Behind the scenes, Windows maps read-only pages to the same physical memory and maps writeable pages as copy-on-write (i.e. a copy is made the first time the page is written to). The programmer shouldn't worry about this.
If you need to share data between different copies of a DLL, you should either mark a section of the image as shareable and ask the compiler to store your shared data there, or use memory-mapped files. Memory-mapped files are generally easier to understand.
The DllCanUnloadNow entry point is only relevant to, and called by, COM. The COM runtime calls it when releasing an object instance or calling IClassFactory::UnlockServer (not necessarily immediately). If it returns TRUE , COM will eventually call FreeLibrary to unload the DLL.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Mike Dimmick wrote:
If you need to share data between different copies of a DLL, you should either mark a section of the image as shareable and ask the compiler to store your shared data there
humm, hard to agree with you. I think long back (in 32bit windows) i have used global variable for reference count, may be it was static, dont exactly remember it. But certainly i did not declare the memory area as shareable.
Still Alive!!!
Thank you God.
|
|
|
|
|
I need to initialise the global variables, so when I attempt the following, an error message appears.Any suggestions appreciated
in stdafx.cpp file
#include "stdafx.h"
int g_SomeGlobalVariable = 0;
and in stdafx.h file
extern int g_SomeGlobalVariable = 0;
|
|
|
|
|
Omit the "extern int g_SomeGlobalVariable" in the header file. You must use this "extern"-statement in the files from which you want to access your global variable (it's only for the linker).
MS
|
|
|
|
|
You needn't to do that. Let the declaration in the stdafx.h (because stdafx.h is included in all source files generated by AppWizard), but omit the initialization ( = 0 ). Global and static variables must be initialized only in the source file.
Robert-Antonio
"Czech Railways discovered, that in case of disaster the most damaged wagons were the first and the last. So they decided to create trains without them."
|
|
|
|
|
I don't know if you are completely right. Certainly, you get an errormessage on an assignment in a header file. But in this case I wouldn't be amazed if the whole "extern"-statement is a problem, because his globalVar isn't "extern" in this case. I didn't try out. Anyhow, I wouldn't place an "extern"-statement in the stdafx.h, even because it is included everywhere else. But that's a question of the point of view.
MS
|
|
|
|
|
Another way of doing the same would be declare it static. So in the stdafx.h you can write like
static int gi_var = 0;
|
|
|
|
|
That wouldn't be a true global variable then. That makes n variables all with file scope.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
There is nothing wrong with declaring a variable extern and then defining it in the same compilation module.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
I've created an mfc dialog-based app, and a menu-resource. But I'd like the menu to appear in the dialog (at the moment it isn't appearing). I know I have to call some kind of CWnd::*** function, but which?
In other words: I have a menu resource, and I want to use it by displaying the menu in the GUI!
This is the most simple kind of menu, but I can't show it
|
|
|
|
|
Put this code in you OnInitDiaog()
CMenu menu;
menu.LoadMenu(ID_OF_MENU);
SetMenu(&Menu);
menu.Detach();
DrawMenuBar();
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Declare an object of CMenu in the CDialog derived class
CMenu m_Menu;
In the overridden OnInitDialog member function call -
m_Menu.LoadMenu(<menu ID>); //load menu.
SetMenu(&m_Menu); // set menu for the dialog window.
This should work.
|
|
|
|
|
Hi,
can anyone tell me how to get the list of all files
used by the user while he is logon on the system.
i.e i want to get the listing of all the files
accessed while he was log-on, how much time he has used each file. etc.
does any one have any idea. or a url of any project.
which give such facilities.
|
|
|
|
|
You'll need a file system driver that monitors file system device objects for IRPs and FastIO requests directed at the drives on your computer.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i want to scan PCI slot which has how many sound card affixed in my computer using with visual C++ programming?
|
|
|
|
|
I HAVE DEVELOPED A PROGRAM WITH VISUAL BASIC SCRIPT, THIS PROGRAM WRITES A FILE CONTAINING SOME TEXT LINES, I CAN'T READ THIS FILE WITH C++ TECHNOLOGY. I THINK THAT THE PROBLE IS BECAUSE VBS WRITES UNICODE AND C++ READS ANSI.
CAN SOMEONE HELP ME AND SEND SOME EXAMPLE CODE?
THANKS.
VISUAL C++
|
|
|
|
|
Script code:
Dim fso
Dim file
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.CreateTextFile("c:\myfile.txt", true)
file.WriteLine("This is a line in my file")
file.Close
C++ (MFC) code:
CStdioFile file("c:\\myfile.txt", CFile::modeRead);
CString strLine;
file.ReadString(strLine);
file.Close();
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
hi..
i am useing Inno programe to build a setup file for vc++
application but when i extract the setup file in other computer (no Visual stdio is installed their )
an error message is came up when the installation is finised and lunch the program
it say:
the dynamic library MFC42D.DLL could not be found in the spacified path C:\Program Files\F.T.P;.;C:\WINNT\system32;C:\WINNT\system;C:\WINNT\system32;C:\WINNT;C:\WINNT\system32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN
i tried to build it again but invlued LIB directory of MFC folder in VS directory but it also did not work
So any help???????????????
|
|
|
|
|
You need to build ur application in Release mode before you disturbute ur application.. MFC42U.DLL is usally shiped with VS for debugging the code.
But MFC42.dll is shiped with the OS itself.
Still Alive!!!
Thank you God.
|
|
|
|
|
I'm sure it was only a typo, but MFC42U.DLL is the UNICODE version of MFC42.DLL, while MFC42D.DLL is the DEBUG build of MFC42.DLL, and cannot be shipped with your app, as it will break the license agreement for VC or Visual Studio
Steve S
|
|
|
|
|
Steve S wrote:
I'm sure it was only a typo
humm, he did say that MFC42D.dll is missing and not MFC42U.dll.
Still Alive!!!
Thank you God.
|
|
|
|
|
|
oke i rebuild my application in Release mode and use Inno
after in the add files option i add the MFC42U.DLL and
MFC42.dll from C:\WINNT but it also did not work and the generated program with different icon and olny welcome and goodby messages apears
|
|
|
|
|
Since you said that ur application showed some welcome message it means that the application worked but the logic of the application did not work. You need to cross check that some times the applications build in debug will work and in release it wount because of silly errors that in debug would not be an inssue but in release build it does, like assigning the pointer to null or initializing the member variables to default values while creating etc.
Still Alive!!!
Thank you God.
|
|
|
|