|
Yes, a DLL can only be loaded once into a process. If you try to load it again, all that happens is the DLL's ref count is increased. Since there is only one instance of DLL X in the process, there is only one foo.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
peterchen wrote:
do (A) and (B) share the same instance of foo?
According to this article[^], only the code is shared. Each instance of the DLL gets its own data segment. The article cited above explains how to get around this issue.
Good Luck!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Netmeisters,
I am trying to use the Canon SDK from a C++ project. The SDK declares callbacks as
cdUInt32 cdSTDCALL MyEventCallbackFunction (etc)
{
}
and the callback is installed as:
CDRegisterEventCallbackFunction(
....
&MyEventCallbackFunction,
....)
Here, cdUInt32 is just a typedef for UInt32, and cdSTDCALL seems to be a typedef for __stdcall.
The problem is that I am using C++, so want to use a member function for the callback. I.e., something like
cdUInt32 MyClass::MyEventCallbackFunction
but this seems not to work.
Is there any way of getting it to work?
Your suggestions much appreciated.
|
|
|
|
|
Try
static cdUInt32 __stdcall MyEventCallbackFunction(etc)
as your declaration.
You generally can't use a member function for a callback, since it has an extra (invisible) parameter, namely "this". However, if you have a static member function, there is no "this", and hence, no extra parameter. Of course that does mean you can't access any instance specific object data, unless you also have an idea of what object you want to tinker with...
Steve S
|
|
|
|
|
MyClass::MyEventCallbackFunction must be a static member function.
John
|
|
|
|
|
What is the best way to debug STL containers in a Visual C++
project ? Like examining the contents of vector, set and maps
Thanks
-Pradeep
|
|
|
|
|
pradeep_cherukat wrote:
What is the best way to debug STL containers in a Visual C++
project
Use stlport. It has a debug mode that informs you when your code tries to do something illegal with a stl container (like use a bad index in a vector).
http://www.stlport.org/[^]
pradeep_cherukat wrote:
Like examining the contents of vector, set and maps
This is a different matter as VC is no help here at all. I believe the only way is to have parts of your code dump the container to a log or something similar...
John
|
|
|
|
|
Containers of what? If you have containers of string's, try FeinEvaluatorPro form FeinSoftware (www.FeinSoftware.com).
|
|
|
|
|
This is my first real exposure to Unicode Base64 Binary data-types; in so far as having to actually deal with them myself. So here's the break-down:
I have a data value that is stored as an encoded Base64Binary. I decode this data value, using a small C routine, and end-up with a string value such as "base64:RGHHGH ..."
I now want that value converted as it's actual STRING data type (the actual data is a GIF image).
Can anyone supply me with the steps, code, function necessary to accomplish this task? I MUST keep this compliant through Windows 98, so please keep that in mind.
Thank you in advanced for any help
D.
|
|
|
|
|
Douglas Troy wrote:
and end-up with a string value such as "base64:RGHHGH ..."
since you want to convert it to actual STRING, i would like to know what is the current data type??
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Excuse my misuse of data-type terminology, since it is currently a char* value.
I've decoded the Base64Binary into a char* that now holds the data as "base64:..." this, however, is still not correct, since the actual data is a GIF image (e.g., "Gif89 ..."). In C#, once decoded, I would then use the AsciiEncoding.GetString() method to get the 'string' result of this data value.
I need a C++ equivalent of that C# function.
D.
|
|
|
|
|
Whell char* is a string,
if you using MFC then you can do this
CString strText;
strText = decodedstring;
or check out string of STD::String, i have not used it so little idea bout it. but still the current data type is string too.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Either I'm not explaining myself clearly or you're not understanding the context of the actual problem. I know what a string is, as char*, string and CString; that is not the issue at hand. My problem lies with a Base64Binrary data-type that, when converted through a MIME decode algorthim, decodes as "base64:RG0...." and not back to it's original data value (which should be a GIF image). I am therefore seeking the algorthim to handle the second portion of the decode, or one that will convert the data back to it's proper format through one-pass.
D.
|
|
|
|
|
Sorry, i got your question wrong.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Hi,
I have a classic Win32 DLL (including it's sources), which is imported into project implicitely.
Can I somehow control the path from where the DLL is loaded, while leaving the DLL import implicit? (i.e. not use the default LoadLibrary strategy)
Flirt harder, I'm a Coder
mlog || Agile Programming | doxygen
|
|
|
|
|
humm,Well i am not giving you a solution just a thought though.
you mean to say that if there are 2 different versions of the same dll in the path then you want to control which dll to load, rite???
If I got that rite, then i guess that exactly is one of the problem why COM evolved.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Yup I know... But the interface is *very* Win32, and I don't want to convert it to COM. I was thinking of the same way, more or less.
Actually, the Win32 way would be acceptable for the release, but I'm looking for a solution during debug...
Flirt harder, I'm a Coder
mlog || Agile Programming | doxygen
|
|
|
|
|
humm, Seems like there is no easy workaround otherwize you would have already got it.
I understand ur prob, during development this kinda prob arises. How i have done is that the dll should not be in any path instead it's binary output should be in the same directory of the output path of the host binary file(I assume the host is also developed by you).
This way if the host binary is diff, say debug or release, then appropriate dll will be loaded.
Well i dont know the sol that you are asking for, but i guess its just a precaution that need to be taken to avoid versioning problem,
I also time n again search for the dlls (development ones) in the root project folder and delete them.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
i have created a dialog windows application using the app wizard.
it has a few other sub dialogs which are created from code behind file menu bar.
Im looking for a method to get access the main dialog windows data from the other sub dialogs.
im sure their is any easy way to get a pointer to the data ?
|
|
|
|
|
if the data is in the main dialog class, you need to pass a pointer of that dialog to the sub-dialogs.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello,
GetParent() returns the main dialog pointer.
CWnd* GetParent( ) const;
Regards,
Hadi
|
|
|
|
|
I would like to create several rectangles overlapping each other but having a transparent look. How can I achieve this by not using bitmaps but regular GDI functions, such as Rectangle(), etc.
Thanks
|
|
|
|
|
Might help: "An application sets the foreground mix mode by using the SetROP2 function and retrieves the current mode by using the GetROP2 function."
These are only for binary raster ops though. Not sure how you would control the mix amount with a setting for alpha blend amount.
|
|
|
|
|
I develop an application (electrical train) where I want to add some sound: a bakground music and some noise depending on my application events.
I used SndPlaySound but it just allow to play .wav file and only one and the same time.
I need to play .mp3 file and add some .wav noises to be more funny
Can someone indicate me which MFC function to use with some exemples.
Thanks a lot....
NKH
|
|
|
|
|
Hello,
The best way for playing .MP3 and .WMA files is DirectShow
There's many libraries on the internet that could do it too.
I'm sure that you can find some samples about playing mp3 files from CP site. ( i saw some good audio players and etc. )
hmm, MCI is another way
Regards,
Hadi
|
|
|
|