|
WPCAP should be all capitals, right?
You can't show the offending lines of code? Please?
I don't have pcap.h, so I can't try it, but I imagine windows header files need to be included
before or after it because of some name conflict or something. You may want to change where you
include that file. I can only guess without seeing it.
Mark
This episode brought to you by the number 5
|
|
|
|
|
Do you by any chance introduced such code in you project:
extern "C" {
#include "SOMEHEADER.h"
}
where SOMEHEADER may be wspiapi.h or any header file that may use wspiapi.h.
|
|
|
|
|
Whene i click on error it's show this line : template < typename __CountofType, size_t _N >
I don't add Wspiapi.h, i just adding pcap.h and inc.h, i don't see a Wspiapi.h in Solution Explorer!!
Thank you verry mutch
|
|
|
|
|
I see the template declaration in the newer wspiapi.h and I downloaded WinPcap.
Including pcap.h worked fine for me.
Where are you including pcap.h?
This episode brought to you by the number 5
|
|
|
|
|
I am trying to convert an HICON to a PNG in memory. I am able to do this operation but on certain icons, like the XP Drive Icons or anything that uses XP shadowing, I get blotchy edges for the shadow. It looks like the transparency on the shadow is not being converted properly.
Below is how I am doing the conversion. I am wondering if more manual labor is required and if anyone knows what that could be. I am not a graphics expert.
In my application, the HICON handle is from a call to SHGetFileInfo. I am retreiving a file's 16x16 icon, including overlays, which I need in PNG format.
// encoder is "image/png"
int sh_icon2img(unsigned char *out, int outl, HICON icon, CLSID encoder)
{
int size;
ULONG ul;
IStream *s = NULL;
Bitmap *bmp;
ULARGE_INTEGER lisize;
LARGE_INTEGER offset;
if(CreateStreamOnHGlobal(NULL, TRUE, &s) != S_OK)
{
return -1;
}
/* create the Bitmap object and save to stream */
bmp = new Bitmap(icon);
bmp->Save(s, &encoder, NULL);
delete bmp;
/* get stream size */
offset.QuadPart = 0;
if(s->Seek(offset, STREAM_SEEK_END, &lisize) != S_OK)
{
s->Release();
printf("Failed to get the size of the stream!");
return -1;
}
size = (int)lisize.QuadPart;
/* seek back to beginning of stream */
s->Seek(offset, STREAM_SEEK_SET, NULL);
// provided buffer is too small
if(outl < size)
{
s->Release();
return -1;
}
if(s->Read(out, size, &ul) != S_OK || size != (int)ul)
{
s->Release();
return -1;
}
s->Release();
return size;
}
Thanks in advance.
|
|
|
|
|
Hello,
I have written a mathematical matrix class
for VS C++ 6 and I would like to publish it
in your site in the form of a library (*.lib).
Maybe later I release the code too.
However I am facing serious problems with my linker
an I 'm not sure if I will ever manage to publish it (at least in
a reasonable amount of time) without your help. So,
I would like to ask you if you could help me a bit.
I am willing to refer your name in my article.
Although, it may take me some time to write it.
As far as I have understood, it is the MFC (used by my
class) that conflicts when I try to use my compiled
*.lib file. I tried to change the settings of my linker
(/NODEFAULTLIB) but I do not find the process familiar!
I have uploaded the *.lib file and the header file so that
you can test it on your own. It is at:
http://rapidshare.com/files/41398859/LIB.zip[^]
The process of compiling it into a LIB file seems to be OK.
I will sum it up if you want:
I added my header file and my cpp file into the project
(Win32 Static Library) and I just built the lib files
with no errors.
Then I created a new MFC app (Dialog, MFC statically linked -
I don't know if that matters), I added the header file and the
lib files into the project, I added the
#ifdef _DEBUG
#pragma comment(lib, "mat_lib_DEBUG.lib")
#else
#pragma comment(lib, "mat_lib_RELEASE.lib")
#endif
in the code file using my class. But it just does't work.
If you manage to compile a project while using an object
please upload the project, so that I can see what I was
doing wrong. If you wan't you may write sth here too.
To use an object of the class write:
CKelLib::CKelMatrix m,n(2,1);
double p[4][4]={{1,2,3,4},{3,6,9.2,12.9},{7,14,21,27},{3,4,9,12.3}};
m.Initialize((double*)p,4,4);
Any kind of help would be appreciated.
Thank you.
kostas KEL
|
|
|
|
|
KEL3 wrote: But it just does't work.
what makes you think it doesn't work?
|
|
|
|
|
The dozens of linker errors I get.
kostas KEL
|
|
|
|
|
KEL3 wrote: The dozens of linker errors I get.
And those would be?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
--------------------Configuration: mat_lib_test - Win32 Release--------------------
Normally I get:
--------------------Configuration: mat_lib_test - Win32 Release--------------------
Linking...
msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
mat_lib_test.exe - 6 error(s), 3 warning(s)
---------------------------------------------------------------------------
After a few /nodefaultlib:***
mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib
I get:
Linking...
LINK : warning LNK4049: locally defined symbol "_malloc" imported
LINK : warning LNK4049: locally defined symbol "_free" imported
LINK : warning LNK4049: locally defined symbol "_time" imported
LINK : warning LNK4049: locally defined symbol "__mbscmp" imported
mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX
mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand
mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand
mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil
mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor
mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof
Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals
Error executing link.exe.
mat_lib_test.exe - 7 error(s), 4 warning(s)
-----------------------------------------------------------------------------
Now we have problems with mathematical functions mostly.
Any ideas?
kostas KEL
|
|
|
|
|
KEL3 wrote: Any ideas?
Have you seen this, that, and the other?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Generally,
I looked up the error codes
but this is the first library
I build and the whole
linker-directives thing causes
me a headache!
I 'll try again though...
kostas KEL
|
|
|
|
|
MFC applications cannot include <windows.h>!
Why don't you compile your matrix library with the same dependency as the MFC project that needs to use it? Anyway, the conflict occurs between libcmt.lib and msvcrt.lib, thus you can try removing one of them and keep the other... see which one (we can't 'cause don't have the source code).
Regards,
|
|
|
|
|
Ok! My problem was solved!
All I had to do was
to use MFC in a shared DLL
in my application, as I did in my class.
No linker directives at all!
I guess that for apps using MFC in a static
library you use MFC in a static library for
your class... I 'll try this later.
Thank you Borish.
Thank you all,
I 'll thank all of you, more, in my future article.
BUT, Borish, what do you mean by "MFC applications cannot include !"?
I include headers all the time in my MFC apps. Is there sth you can not include?
kostas KEL
|
|
|
|
|
Sorry... that must be a typo, or a glitch when submitting a post (maybe interpreted as html code, 'cause I've used the xml kinda brackets)!
I meant MFC applications cannot include windows.h...
Very glad to hear that you solved your compilation issues.
Congrats!
|
|
|
|
|
I want to delay in the middle of my code without cpu usage , I mean I dont want to use things like timer . if there is any function or algurithm like delay() in turbo C .
thanks
|
|
|
|
|
V_shr wrote: I want to delay in the middle of my code without cpu usage , I mean I dont want to use things like timer
are you talking about the Windows timer (OnTimer, SetTimer) ? that's the simplest way to do what you describe.
|
|
|
|
|
|
|
|
Hi All,
i have an MFC application receive event message and based on the message type to new "Order" object. the created object stored in a map and never delete thro' the application cycle.
my "Order" class size only < 1k byte. however, the application memory grow as 100k per order inputted.
i added the CRT memory leak statement (use _CrtMemDifference, _CrtMemCheckpoint) to see the difference after executed function for each event. the result can show the object size (Order class) i created. however, the 100K grow rate still not able to show.
questions:
A) i wonder i dont know what reflect in those functions. anyone have idea on this?
B) more effective question is how can i print the memory size of my application?
so, i can check the memory usage difference for each big function call and drill down the problematic function.
like this :
printf("b4 handler"); printMemSize();
BigHandler();
printf("after handler"); printMemSize();
any reply will be highly appreciated!
thanks!
jim
|
|
|
|
|
Maybe try something like this:
#ifdef _DEBUG
class _MemStateCheck
{
public:
CMemoryState oldMemState, newMemState, diffMemState;
_MemStateCheck();
~_MemStateCheck();
};
_MemStateCheck::_MemStateCheck()
{
oldMemState.Checkpoint();
}
_MemStateCheck::~_MemStateCheck()
{
newMemState.Checkpoint();
if( diffMemState.Difference( oldMemState, newMemState ) )
{
TRACE( "************************\n" );
TRACE( "Memory leaks Detected\n" );
TRACE( "************************\n" );
diffMemState.DumpStatistics();
diffMemState.DumpAllObjectsSince();
}
else
{
TRACE( "************************\n" );
TRACE( "No memory leaks Detected\n" );
TRACE( "************************\n" );
}
}
_MemStateCheck MemCheckObj;
#endif //#ifdef _DEBUG
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
The code in the first block checks for leaks between the construction and destruction of the
static _MemStateCheck MemCheckObj variable. It also shows how you can get memory checkpoints
and dump the difference between them to the debugger output window.
The code in the second block sets the use of the debug new operator and insures file/linenumber
info is available so the leak dump has more useful information.
Mark
This episode brought to you by the number 5
|
|
|
|
|
Thanks! Mark.
This is what i did but i used the _CRTMemXXXX function from crtdbg.h. i guess your CMemoryState is from MFC.
I have i question. If there is no memory leak, but i want to print the app's allocated memory size (sth like the "memory" column in task manager). Any function can serve this purpose?
thanks!
jim
|
|
|
|
|
|
Mark,
Thank you for your quick response!
let me take a look!
Jim
|
|
|
|