|
Hello everyone,
I think we can use LoadLibrary to load a .dll file and use its published interface. I am wondering whether there are some methods to un-load a library (which is adverse to LoadLibrary)?
thanks in advance,
George
|
|
|
|
|
|
Thanks Rick!
This link is dealing with how to load a library. But my question is about how to unload a library.
regards,
George
|
|
|
|
|
|
Hi Mihai,
This method is very useful. After reading through related MSDN documentations, I have two questions about this,
- How to verify that the library is unloaded? How to write a simple program to verify that the library is real unloaded by the application -- maybe I can try to invoke some functions provided by the .dll after unloading it? Do you have any ideas?
- Is the method FreeLibrary Microsoft C++ standard or standard C++ standard? Could it be used in C program?
Thanks a lot!
regards,
George
|
|
|
|
|
Hi George,
1) the FreeLibrary function is returning a TRUE/FALSE value to verify if it's unloaded, and you shouldn't invoke other function after you unload it (my advice).
2) that's a Microsoft Windows method specific and it's not in the pure C++ language.
|
|
|
|
|
Thanks Mihai,
If I want to use it in pure C++ language, which similar method should I use?
regards,
George
|
|
|
|
|
I need help.I am trying to get the dc of a GDI+ Bitmap dirctly
During runtime i am loading the image in Gdiplus::Bitmap m_gdipBmp;
with out showing it dirctly into view i want to get the dc of this bitmap
I have used this code
Gdiplus::Graphics g(m_gdipBmp);
HDC hDC = g.GetHDC();
but i am not getting the proper dc
|
|
|
|
|
I have some code which is generate by VC6.0 sp5, it is a SDI based project. When i compile it in VS.NET 2005, there are a lot of errors and warnings, and i don't want to rewrite my code? what should i do then? help me please!
|
|
|
|
|
Can you please tell me what kind of errors do you get? Maybe I can help you!
|
|
|
|
|
First: I drag the project file XXX.dsw directly to the .NET IDE, it give me a tip to convert this project, i choose yes. After convert it, i press F7 to build the solution, its errors are:
------ Build started: Project: PWSpy, Configuration: Debug Win32 ------
Compiling...
StdAfx.cpp
Compiling...
Gradient.cpp
d:\workshop\file system\all codes\monitor ap\pwspy\gradient.cpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\workshop\file system\all codes\monitor ap\pwspy\gradient.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\workshop\file system\all codes\monitor ap\pwspy\gradient.cpp(179) : error C2065: 'i' : undeclared identifier
MainFrm.cpp
d:\workshop\file system\all codes\monitor ap\pwspy\tballoon.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\workshop\file system\all codes\monitor ap\pwspy\gradient.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(88) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(89) : error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CMainFrame::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(90) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(94) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(UINT,LONG)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(95) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(96) : error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CMainFrame::* )(UINT,DWORD)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(97) : error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CMainFrame::* )(UINT,DWORD)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(1421) : error C2065: 'nDevIndex' : undeclared identifier
d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(1913) : error C2593: 'operator +=' is ambiguous
d:\microsoft vs .net 2005 ide\microsoft visual studio 8\vc\atlmfc\include\cstringt.h(1372): could be 'ATL::CStringT<basetype,stringtraits> &ATL::CStringT<basetype,stringtraits>::operator +=(wchar_t)'
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>
]
d:\microsoft vs .net 2005 ide\microsoft visual studio 8\vc\atlmfc\include\cstringt.h(1365): or 'ATL::CStringT<basetype,stringtraits> &ATL::CStringT<basetype,stringtraits>::operator +=(unsigned char)'
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>
]
d:\microsoft vs .net 2005 ide\microsoft visual studio 8\vc\atlmfc\include\cstringt.h(1358): or 'ATL::CStringT<basetype,stringtraits> &ATL::CStringT<basetype,stringtraits>::operator +=(char)'
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>
]
while trying to match the argument list '(CString, int)'
PWSpy.cpp
d:\workshop\file system\all codes\monitor ap\pwspy\pwspy.cpp(144) : warning C4996: 'CWinApp::Enable3dControls' was declared deprecated
d:\microsoft vs .net 2005 ide\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(4471) : see declaration of 'CWinApp::Enable3dControls'
Message: 'CWinApp::Enable3dControls is no longer needed. You should remove this call.'
PWSpyDoc.cpp
PWSpyView.cpp
TBalloon.cpp
d:\workshop\file system\all codes\monitor ap\pwspy\tballoon.cpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\workshop\file system\all codes\monitor ap\pwspy\tballoon.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\workshop\file system\all codes\monitor ap\pwspy\gradient.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
d:\workshop\file system\all codes\monitor ap\pwspy\tballoon.cpp(163) : warning C4018: '<' : signed/unsigned mismatch
Generating Code...
Creating browse information file...
Microsoft Browse Information Maintenance Utility Version 8.00.50727
Copyright (C) Microsoft Corporation. All rights reserved.
Build log was saved at "file://d:\WorkShop\File System\All Codes\MONITOR AP\PWSpy\Debug\BuildLog.htm"
PWSpy - 10 error(s), 9 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
Syouki_kou wrote: d:\workshop\file system\all codes\monitor ap\pwspy\mainfrm.cpp(89) : error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CMainFrame::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
With regards to the messages of the type I've quoted above, maybe I can help.
I remember getting these when I also moved from VS6 to VS7.1.
The new compiler seems to be a lot stricter when it comes to message function prototypes.
I am assuming these functions are message handlers (used in the ON_MESSAGE macro). The prototype required by 7.1 is :
LRESULT memberFxn( WPARAM, LPARAM ) .
With VS6.0, you could get away with this allowing a void or a BOOL return type. Even the WPARAM / LPARAM parameters could be tweeked and the compiler would not complain. VS7+ does not give you this flexiblity anymore.
For these type of errors, you will need to go to these functions and change then to the expected prototype. So for example, for the quoted error above, you will need to change the return type from BOOL to LRESULT.
I would also think that the majority of the other compiler errors have similar solutions.
I Dream of Absolute Zero
|
|
|
|
|
Thanks a lot, i have already fix this trouble, but there is another trouble which is cause by ATL, the errors are:
d:\workshop\file system\all codes\monitor ap\pwcontext\PWFormat.h(33) : error C2787: 'IContextMenu' : no GUID has been associated with this object
d:\workshop\file system\all codes\monitor ap\pwcontext\PWFormat.h(33) : error C2440: 'initializing' : cannot convert from 'DWORD_PTR' to 'const IID *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Generating Code...
This is a simple coding which follow Michael Dunn[^]'s steps,but can't compile under VS.NET 2005.
|
|
|
|
|
This trouble is already fixed! Thanks for your help, everyone!
|
|
|
|
|
as VC6 compiler was far from being standard compliant, even if you don't rewrite your whole application code, you'll have to fix some parts, maybe by rethinking them.
i'm sorry, there's no other way if you still want to compile under VC2005
|
|
|
|
|
Sometimes I wish I had started this project in MFC rather than plain old Win32. When I have finished I think I should go learn MFC and make use of the classes.
Anyway, I am displaying a bitmap in the client area of a dialog. I have no problem with this, but I now want to add some extra functionality. For example I want the user to be able to zoom-in and zoom-out. This isn't really a big problem, just resize the image and display the relevent part.
But this is where I am stuck. If I enlarge the bitmap to say 200%, only 25% of the image is displayed, how would one normaly scroll this? I have been looking through the controls and have found nothing useful.
In the examples on this website, they do similar but use the MFC controls CView, CScroll, etc... I don't have this option. Is there an easier way to do this than creating 2 scrollbars and handling the messages?
|
|
|
|
|
well first of all create a new child window on the dialog and paint the window on that new window (remember to create the window with WS_VSCROLL and WS_HSCROLL so you have scrollbars).
Then handle the WM_VSCROLL and WM_HSCROLL windows msgs (see MSDN for the parameters these message bring), then you can use ScrollWindow function to actually scroll the window.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
I have one CString which contains "MX1200" as its value. I want 1200 from this and I want to store it in a integer variable. How do I do this? Can you show a small code snippet?
Aljechin Alexander
|
|
|
|
|
look at the two functions
atoi()
itoa()
I maybe wrong but I think the atoi() function will only convert the numerical characters from the string, and skip over the non-numerical.
I don't use MFC myself, but there maybe a better way to do this using the MFC classes, I will leave that to the MFC guru's.
|
|
|
|
|
I know its the CRT function atoi(). But its not working for some reason. Thats why I asked for a code snippet. Someone please helpme out.
Aljechin
|
|
|
|
|
perhaps you could post the code you have created, this would give us a better idea of what you are trying and where you may be going wrong.
|
|
|
|
|
Ok, I just tested what I thought and I was half right. atoi will stop at the first non-numerical char, so if your string start with letter you have to remove them.
char *txt = "MX2001";
char *buffer = new char[10];
int pos = 0;
int result;
for (int i=0;i<strlen(txt);i++) {
if ((txt[i] > 0x29)&&(txt[i] < 0x40)) {
buffer[pos] = txt[i];
pos++;
}
}
buffer[pos] = 0x00;
result = atoi(buffer);
Or if your string is fairly constant and always the first two are letter you could
result = atoi(&txt[2]);
-- modified at 1:50 Wednesday 22nd March, 2006
Don't forget to use delete or you will have memory leaks;
|
|
|
|
|
Here is a way to do that.
1. Get length of your CString.
2. Declare a char array of that length and copy your CString to that array.
3. Now the number can easily be extracted from that array.
Here is the code to copy CString to char array
int size = myCString.GetLength(); <br />
char *array =(char*)malloc(size + 1);<br />
strcpy(array, myCString);
If problem remains, do let us know.
Good Luck
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Thank you all. Actually I had been a little dumb. I forgot I was doing a unicode build and should have used _wtoi function and not the atoi function .
Thanks for all of your kind replies.
Aljechin
|
|
|
|