|
Hi Richard,
I'm beginner to this area. I also gone through that document you sent me and got some idea.
But unable to conclude any way to get information on loaded DLL.
Actual requirement is to get both Dll's - "physical location" & "Version" information programeically from a Win32(vc++) application.
I tried 2-3 ways but still failing to fulfill my requirement.
Kindly share a detailed way or code then it will great to learn.
|
|
|
|
|
As I said before, you must load the DLL first, using the LoadLibrary() [^] function. Only then can you get the full path details. As to version information, you need the Version Information Functions[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thanks Richard,
Its working fine by using LoadLibrary().
Extracting the DLL's version info - i have check.
Mean while for my knowledge purpose ,can you please clarify one doubt.
Even though we are adding DLL reference through project-proporties, why it was still printing the application's Exe path (please refer the code stuff in my last reply) ??
Thanks
|
|
|
|
|
litu kumar wrote: why it was still printing the application's Exe path I have already explained twice. If the DLL has not been loaded into your application's address space then the call to GetModuleHandle() will return NULL ; something that you have not catered for in your code. If the module handle is NULL then GetModuleFileName() will return the path of your executable program. The sequence you should follow is:
HMODULE hmod = LoadLibrary(TEXT("MyApp.dll"));
if (hmod != NULL)
{
TCHAR szPath[MAX_PATH + 1];
DWORD dwLen = GetModuleFileName(hmod, szPath, MAX_PATH);
if (dwLen > 0)
{
wprintf(L"CURRENT DIRECTORY: %s\n" ,szPath);
}
else
{
}
}
else
{
}
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thanks Richard for above information.
I have a small doubt, kindly clarify -
What is the difference between 'Adding the DLL reference from Project-properties' & 'LoadLibrary(MyApp.dll)' ??
-I mean in each case, how Dlls are being loaded (Dynamically\Statically)
"Adding the DLL reference from Project-properties " means - Right click on Project name -> Referenceses ..->Add New Reference... Then select 'MyApp.dll' from existing directory.
I can guess my answer but not sure. Thats why please ensure me.
Thanks
modified 8-Nov-12 9:07am.
|
|
|
|
|
I have never used dll's by adding to the project references; are you sure we are talking about C++ here? They are either linked in by adding the reference in the Linker properties of your project, or loaded dynamically by the LoadLibrary() function. Which version of Visual Studio are you using?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I'm trying to use another DLL from my Win32 dll.
So we can use external dll in either way.
why i asked that question , because if that external dll having different versions in same system.Then which version its taking while loading.
Actually one client requirement is there -
Our application should load this external DLL irrespective of certain DLL-location.
In above both ways[Adding reference AND LoadLibrary()] of DLL loading ,we are explicitly giving a DLL location Or placing the DLL in the same project location.
IS there any way we can make DLL to load independently(we'll not give explicit dll location or DLL itself).
Thanks
|
|
|
|
|
I'm not sure I fully understand what you are asking. However, you can include a library in your build process by adding the .LIB file to the linker input. This will add a reference to the associated DLL to the final program. At execution time the system will load the DLL when necessary, by searching for it in the standard library directories. If you wish to load it yourself using the LoadLibrary() function, then you can provide just the name, in which case the system will search for it as before, or you can provide the full path to an alternate version that you have installed elsewhere.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
hello everyone
we are hacker union Game source code group
We can help you get
someone or company file.photo.Record.Game source
code.
Have any questions about computer aspect need to
please contact us
plenty of Game source code. to sell or get to
designated game code
Yahoo Messenger:hacker240union
mail:hacker240union@yahoo.com.cn
|
|
|
|
|
Environment: Windows 7, Visual Studio 2008, C++ MFC
Question:
How does class AsyncSocket for the server side detect and notify the application when the client closes the connection?
Details:
I wrote the async article found here: Asynchronous TCP Part 1 as a learning tool. Now that I am using that knowledge in a working project I find that when the client closes the socket, I don’t see any results on the server side. I was expecting that OnClose() would be called, but that does not happen. On the client side, after closing, no data can be received until it is Initialized and connected again.
The problem is that in the real application, when the client closes and re-connects the interface protocol for the client requires that the server send some specific information. I am not seeing a way to detect that closure.
Edit: OnClose is declared public. That was an answer in another thread.
And again: I do not have the client code and have no control over the client side behavior.
and again: continued searching yielded something about the read() method getting a result or error. This server application never receives any data from the client and uses no reads. Do I still need to post a read to get a close status?
POSSIBLE ANSWER
My application uses C_Server, decended from CAsyncSocket, to post the Listen and call Accept(). In the call to Accept it creates an object from C_Server_Send to communicate with the client. When I add code to post a receive from C_Server_Send, and then close the client, OnClose() from C_Server_Send gets called. So, empirically, I conclude that Yes, I must post a receive to enable detection of client disconnect. Is that correct?
NEW PROBLEM:
How is C_Server_Send to be deleted.
First: C_Server_Send was newed from C_Server, but that object can create an indefiniate number of C_Server_Send objects as multiple clients connect. Must it keep track of each one.
Second: How does C_Server know that its time to delete an arbitrary instance of C_Server_Send?
Thanks for your time
modified 6-Nov-12 12:54pm.
|
|
|
|
|
Visual Studio, MFC, C++, Windows 7
I need to create some GUIs that I consider to be intermediate level, definatly more than the standard tutorial presents. Included is the ability to divide the screen into multiple areas and to dynamically draw some simple block diagrams with lines between the blocks with colors and labels.
Does someone have a link to some good articles or good books to suggest?
Thanks for your time
|
|
|
|
|
You probably need to look into Splitter Windows[^] and GDI+[^] for creating graphics. There are also some articles on GDI+ here[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
char buffer[50]
int offset =3;
char Buffer[250];
sprintf_s(&buffer[offset],offset,"%s",Buffer);
When we use the above funcation and application crashed with the folloing message
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: xyz.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\vsprintf.c Line: 244 Expression: ("Buffer too small", 0)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
OS used : Windows 7 32bit OS
Microsoft Visual Studio 2008 (VC++)
Version 9.0.30729.1SP
|
|
|
|
|
It looks like you are trying to store a 250 character string into a 50 character buffer, and you have told the formatter that the buffer is only 3 characters long. But ultimately your code makes little sense.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
A description I read had GetLastError where I expected WSAGetLastError and my searches did not return those pages. Thanks for the links.
Thanks for your time
|
|
|
|
|
I think you meant to reply on the message thread below.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Even if make 50 char sting into a 50 char buffer, I am getting the same error.
Is there any other way to do this?
The same code works fine in VS6.0 and not in VS2008.
|
|
|
|
|
As I said before, you are specifying a buffer size of 3, so any number of characters greater than that will cause the error. Check the documentation[^] for specific details of the parameters and their values.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Member 9353776 wrote: char buffer[50]
int offset =3;
char Buffer[250];
sprintf_s(&buffer[offset],offset,"%s",Buffer);
I am trying to guess what your code is supposed to do here but this might be closer to what you want:
char buffer[50]
int offset =3;
char Buffer[250];
sprintf_s(&buffer[offset], sizeof(buffer) - offset, "%s", Buffer);
The second parameter of sprintf_s as used here is the maximum allowed length of the output buffer. If the buffer is of size 50 and you want to write starting in element 3 then the obvious size remaining is 'sizeof(buffer) - offset' and not 'offset'.
HTH
--
Harvey
|
|
|
|
|
Visual Studio 2008, MFC, C++
What is the difference between WSAGetLastError() and GetLastError()?
Thanks for your time
|
|
|
|
|
You can check by looking here[^] and here[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Dear Friend,
I wrote one code working fine in VC6 BUT throwing ASSERTIONS in VS2010 (NOT SP1). [Debug Mode only]
#include
typedef map<cstring, int=""> MapString2Int;
int main()
{
MapString2Int mapString2Int;
mapString2Int[_T("ABC")] = 20; /// Throw error
mapString2Int[_T("XYZ")] = 40; /// Throw Error
}
It saying "map/set insert iterator outside range"
Thanks,
Subhash
|
|
|
|
|
You have not defined the types in your map template; the above code does not even compile.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
im trying to copy a cimage dib to the clipboard. the second
memcpy fails with a read access violation. can anyone help?
CImage tmpImage = pDoc->m_imageArray[0];
int w = tmpImage.GetWidth();
int h = tmpImage.GetHeight();
int Bpp = tmpImage.GetBPP();
BITMAPINFOHEADER bmInfohdr;
bmInfohdr.biSize = sizeof(BITMAPINFOHEADER);
bmInfohdr.biWidth = w;
bmInfohdr.biHeight = -h;
bmInfohdr.biPlanes = 1;
bmInfohdr.biBitCount = Bpp;
bmInfohdr.biCompression = BI_RGB;
bmInfohdr.biSizeImage = w*h*Bpp;
bmInfohdr.biXPelsPerMeter = 0;
bmInfohdr.biYPelsPerMeter = 0;
bmInfohdr.biClrUsed = 0;
bmInfohdr.biClrImportant = 0;
BITMAPINFO bmInfo;
bmInfo.bmiHeader = bmInfohdr;
bmInfo.bmiColors[0].rgbBlue=255;
void* pBits = tmpImage.GetBits();
HANDLE hData = ::GlobalAlloc (GMEM_MOVEABLE, sizeof(BITMAPINFO) + w * h * 3);
LPVOID pData = (LPVOID) ::GlobalLock (hData);
LPBYTE p_imagebits;
p_imagebits = (LPBYTE)pData + sizeof(BITMAPINFO);
memcpy(pData,&bmInfo,sizeof(BITMAPINFO));
DWORD dwBytes = ((DWORD) w * Bpp) / 32;
if(((DWORD) w * Bpp) % 32) {
dwBytes++;
}
dwBytes *= 4;
unsigned long m_dwSizeImage = dwBytes * h;
memcpy (p_imagebits, pBits, m_dwSizeImage);
::GlobalUnlock (hData);
COleDataSource* pods = new COleDataSource;
pods->CacheGlobalData (CF_DIB, hData);
pods->SetClipboard ();
|
|
|
|
|
It fails because the memory allocated by GlobalAlloc is not enough. See, how you use sizeof(BITMAPINFO) + w * h * 3 value to allocate memory, and then you are trying to calculate the m_dwSizeImage value, which is much greater then requested.
You have got two options:
Either move this chunk of code after you have calculated the image size, so that your code becomes:
DWORD dwBytes = ((DWORD) w * Bpp) / 32;
if(((DWORD) w * Bpp) % 32) {
dwBytes++;
}
dwBytes *= 4;
unsigned long m_dwSizeImage = dwBytes * h;
void* pBits = tmpImage.GetBits();
HANDLE hData = ::GlobalAlloc (GMEM_MOVEABLE, sizeof(BITMAPINFO) + m_dwSizeImage);
LPVOID pData = (LPVOID) ::GlobalLock (hData);
LPBYTE p_imagebits;
p_imagebits = (LPBYTE)pData + sizeof(BITMAPINFO);
memcpy(pData,&bmInfo,sizeof(BITMAPINFO));
memcpy (p_imagebits, pBits, m_dwSizeImage);
Or, just use a solution[^] from Codeguru
BTW, it looks like you have calculated the m_dwImageSize incorrectly anyway
|
|
|
|