|
Does this[^] link helpful?
|
|
|
|
|
Thanks whitesky, but I need it to go the other way PDF to HTML. That looks like it only creates PDF.
|
|
|
|
|
The goal of my code is to filter some specific IP packet,just like the firewall.But one of the function in my code was always failed.The error code is 87(error parameter).I really don't known where goes wrong.I was puzzled of this problem.Any help is much appreciated.
<code>#include "stdio.h"
#include "windows.h"
#include "Fltdefs.h"
#pragma comment(lib, "iphlpapi.lib")
void main(int argc, char* argv[])
{
DWORD err = NO_ERROR;
// Create a filter interface
INTERFACE_HANDLE hInterface;
PfCreateInterface(
0,
PF_ACTION_FORWARD,//PF_ACTION_DROP,
PF_ACTION_FORWARD,//PF_ACTION_DROP,
FALSE,
TRUE,
&hInterface);
// Bind the filter interface to a IP
BYTE localIp[] = {192,168,0,111};
BYTE remoteIp[] = {220,181,38,4};
PfBindInterfaceToIPAddress(hInterface, PF_IPV4, localIp);
FILTER_HANDLE fHandle;
// Fill the filter struct
PF_FILTER_DESCRIPTOR outFilter;
outFilter.dwFilterFlags = FD_FLAGS_NOSYN; always use this
outFilter.dwRule = 0; //always use this
outFilter.pfatType = PF_IPV4;
outFilter.SrcAddr = localIp;
outFilter.SrcMask = (PBYTE)"\xFF\xFF\xFF\x0";
outFilter.wSrcPort = FILTER_TCPUDP_PORT_ANY; outFilter.wSrcPortHighRange = FILTER_TCPUDP_PORT_ANY;
outFilter.DstAddr = 0;
outFilter.DstMask = 0;
outFilter.wDstPort = 1;
outFilter.wDstPortHighRange = 10000;
outFilter.fLateBound = LB_SRC_ADDR_USE_DSTADDR_FLAG|LB_DST_ADDR_USE_DSTADDR_FLAG;
outFilter.dwProtocol = FILTER_PROTO_ANY;
err = PfAddFiltersToInterface(hInterface, 0, NULL,1, &outFilter, &fHandle);
//PfAddFiltersToInterface always failed
if(err != NO_ERROR)
{
int exitcode = GetLastError();
printf("PfAddFiltersToInterface is Wrong\n");
printf("The error exit code is %d\n", exitcode);
//return ;
}
printf("Try to connect to the internet...\n");
char ch=getchar();
printf("Filter Enabled!");
// Remove the filter interface
PfRemoveFilterHandles(hInterface, 1, &fHandle);
PfUnBindInterface(hInterface);
PfDeleteInterface(hInterface);
return;
} </code>
|
|
|
|
|
Hi i am rewriting a piece of MFC(vc++6)code in VS2005 (MFC).
There is a code as shown below..
<br />
ofstream file;<br />
file.open("abc.seg", ios::out|ios::binary);<br />
Is this code wrong. Well as no intellisence IS coming up for ios in this and even in msnd i could not find any info about ios::out and ios::binary..
I guess there must be some changes in the same. Well though i am not getting error at the moment. I can build it. What coudl be the reason...???
So could any one shed some light over it and also what exactly that parameter is doing....
Thanks
SS
|
|
|
|
|
Software_Specialist wrote: ...in msnd i could not find any info about ios::out and ios::binary..
Why not? It's all right here.
"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
|
|
|
|
|
oh thanks
So do we have to now use ios_base instead of ios....
i was looking for ios::out ...So is there any documentation or anything from where i could see what all is changed in VS2005 MFC. I guess in earlier version ios::out and ios::binary was supported...
Thanks for replying back...
|
|
|
|
|
Software_Specialist wrote: So do we have to now use ios_base instead of ios....
No. ios is a typedef of basic_ios , which is derived from ios_base .
"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
|
|
|
|
|
ios is a struct buried away deep in the C files of the runtime (CRT) library your code is linked to e.g. MSVCRT.DLL. out and binary are memebers or enum values or some such of ios which form bit flags for the mode for low level io. Intellisense is a bit lacking on the CRT, especially if the CRT sources are not in your projects source search path.
This stuff is all still valid but a little old fashioned in terms of naming conventions, use of language features and structuring of the code which makes it hard to understand these sources. No worries
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
ah okay
so intellisence doesnt work for ios here...
I was bit cofused because this ios:: gives me intellisence but there is no out or binary option in it. And now i tried with ios_base:: and even this is not giving me any intellisence..So anyway i guess its allright to stick to ios::out and ios::binary as you said..
Thanks a lot
|
|
|
|
|
Software_Specialist wrote: I was bit cofused because this ios:: gives me intellisence but there is no out or binary option in it.
I've not ever seen enum items show up in the Intellisense list.
"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
|
|
|
|
|
DavidCrow wrote: I've not ever seen enum items show up in the Intellisense list.
They show up in VS 2003 .NET
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Nopes they are showin up in VS2005(MFC).
|
|
|
|
|
Hi
I want to display a jpeg format picture in Visual C++ 6 and I want to ask that can I use CImage for that? CImage is under Visual Studio 2005 in msdn wep page.If I can use it in Visual c++ 6 how can I do that? If not is there any other simple way?
Thanks
|
|
|
|
|
You can also use of OleLoadPicture .For CImage class a short code is
#include AtlImage.h
CImage m_Image;
m_Image.Load("C:\\1.hpg");
m_Static.SetBitmap(m_Image.Detach());
Im not sure you can use of CImage on the VC6.0 or no but also on the codeproject is an article its name CXImage.
|
|
|
|
|
WhiteSky wrote: You can also use of OleLoadPicture.
See the requirement here.
"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
|
|
|
|
|
Yeah you right for this link but for current his question he said "If I can use it in Visual c++ 6 how can I do that? If not is there any other simple way?"
|
|
|
|
|
As a last question about this subject when I wrote:
#include "atlimage.h"
It gave an error as:
Cannot open include file: 'AtlImage.h': No such file or directory
Is the error means that CImage is not supported by Visual C++ 6? Or is there anything that can I do about that problem?
Thanks again
|
|
|
|
|
See this[^] thread is helpfuls?
|
|
|
|
|
CImage wraps Windows GDI/GDI+ APIs which are all available for you to use.
The very simplest way I know to load and display a JPEG image is to use GDI+...
Gdiplus::Bitmap MyBitmap(L"C:\\test.jpg", FALSE);
Gdiplus::Graphics MyGraphics(hwnd);
MyGraphics.DrawImage(&MyBitmap, 0, 0, MyBitmap.GetWidth(), MyBitmap.GetHeight());
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I see that CImage is not supported by Visual c++ 6.I want to ask a basic question; Can we add the CImage libraries to Visual C++ 6 manually.If it is possible how can we do that.
|
|
|
|
|
Hello..
I want to do NOT operation..but i here output is wrong..
<br />
main()<br />
{<br />
unsigned int Value=4; <br />
<br />
Value = ~ Value; <br />
<br />
}<br />
but my output is 4294967291 insted of 251.
Please help me out..
Thanks
Shah
|
|
|
|
|
If you only want to use 8 bits, you need to use unsigned char . Int is 32 bit longs, so you get FFFFFFFB when you do the NOT operation.
udy
|
|
|
|
|
Shah Satish wrote: unsigned int Value=4; /* 4 = 0000 0100 */
Actually:
unsigned int Value = 4;
Value = ~Value;
"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
|
|
|
|
|
Actually The output (4294967291 = 0xFFFFFFFB) is correct (your assumptions are wrong) because the unsigned int type is 4-bytes wide:
HEX: ~0x00000004 =
0xFFFFFFFB
BINARY: ~0000 0000 0000 0000 0000 0000 0000 0100 =
1111 1111 1111 1111 1111 1111 1111 1011
if you want to obtain 251 then use the unsigned char type:
unsigned char Value;
Value = 4;
Value = ~ Value;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
not very sure abt this.. bt i guess that if u wanna arrive at 251 ie. -5 (sign extended), u gotta use short int or int instead of unsigned int.
hope this helps
|
|
|
|