Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

pierrekande

@pierrekande
About
Posts
6
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • client-server
    P pierrekande

    I suppose that you have a good level on networking programming then do this if not just forget about, sorry Normaly with Socket API it is not possible, because while calling accept() the client get connect. For that you need to use some firewall in your program for packet filter here is am easy way to do that: INTERFACE_HANDLE hInterface; // interface PFFORWARD_ACTION defaultAction=PF_ACTION_DROP; // create the interface // I create the interface. Predefined acctions, forward all. DWORD errorCode = PfCreateInterface(0,defaultAction,defaultAction,FALSE,TRUE,&hInterface); if(errorCode != NO_ERROR) { return -1; } // Bind the Ip Address with the interface PBYTE lIp = (PBYTE)&ip; //the ip address of your card errorCode = PfBindInterfaceToIPAddress(hInterface, PF_IPV4, lIp); if(errorCode != NO_ERROR) { PfDeleteInterface(hInterface); hInterface = NULL; return -1; } ///////////////////////////////////////////////////// now here do with the code { DWORD result; PIP_ADAPTER_INFO pAdapterInfo = NULL, aux; IP_ADDR_STRING *localIp; unsigned long len = 0; GetAdaptersInfo(pAdapterInfo, &len); pAdapterInfo = (PIP_ADAPTER_INFO) malloc (len); result = GetAdaptersInfo(pAdapterInfo, &len); if(result != ERROR_SUCCESS) { AfxMessageBox("Error getting adapters info."); return; } // Fill the real filter struct PF_FILTER_DESCRIPTOR ipFlt; ipFlt.dwFilterFlags = FD_FLAGS_NOSYN; ipFlt.dwRule = 0; ipFlt.pfatType = PF_IPV4; ipFlt.dwProtocol = protocol; // value is : TCP =6;UDP=17 or ICMP=1 ipFlt.fLateBound = 0; ipFlt.wSrcPort = srcPort; // source port ipFlt.wSrcPortHighRange = srcPort; // source port range ipFlt.wDstPort = dstPort; // destination port ipFlt.wDstPortHighRange = dstPort; // destination port range unsigned long lIpSrc = CharToIp(srcIp); //chartoIP convert (*.*.*.*) to long unsigned long lIpDst = CharToIp(dstIp); unsigned long lMaskSrc = CharToIp(srcMask); unsigned long lMaskDst = CharToIp(dstMask); ipFlt.SrcAddr = (PBYTE) &lIpSrc; ipFlt.SrcMask = (PBYTE) &lMaskSrc; ipFlt.DstAddr = (PBYTE) &lIpDst; ipFlt.DstMask = (PBYTE) &lMaskDst; DWORD errorCode; // I add the filter if(direction == IN_DIRECTION || direction == ANY_DIRECTION) errorCode = PfAddFiltersToInterface(hInterface,1,&ipFlt,0,NULL,NULL); if(direction == OUT_DIRECTION || direction == ANY_DIRECTION) errorCode = PfAddFiltersToInterface(hInterface,0,NULL,1,&ipFlt,NULL); } Not that when stopping your

    C / C++ / MFC question sysadmin help

  • How to Terminate a CWinThread
    P pierrekande

    There is several way to terminate your thread. Let me suppose that you understand about synchronisation. And also to make thing more easier, define a static member variable of type: static BOOL m_endLoop for your dialog class CYourDLG; and also define a static member of type: static CEvent m_EventExit for your dialog class CYourDLG. in the CYourDLG::OnInit() function initialize m_endLoop=0; and call m_EventExit.SetEvent(). And in your function OnCancel and OnOk at before to exit, call WaitForSingleObject(EventExit,INFINITE); and in the first line in those 2 functions set m_endLoop =TRUE; and now in your loop function that terminate the thread, inside the loop insert this code: if(CYourDLG::m_endLoop==TRUE) { // first to some cleaning and close all opened file or whatelse ........... //and call CYourDLG::m_EventExit.SetEvent(); return 0; } ================== BUT when your start the thread insert this line at the begin of the thread function CYourDLG::m_EventExit.ResetEvent(); That is. You will have no access violation. This solution must help. Let me know if you have more questions Perre Kande

    C / C++ / MFC question help tutorial

  • Program compile witn XP Pro SP2 not run on XP Pro SP1, Home and Win2000 SP4
    P pierrekande

    Thank you for your reply, But I have resolved the problem. I have link my app to the all DLL of windows and not to the DLL install on my OS. and running the program in other system, all is fine. This mistake is from MS, because it cause program build on XP Pro SP2 can run in older version if you link only with the old version dll. have it in mind.

    C / C++ / MFC announcement csharp visual-studio

  • Program compile witn XP Pro SP2 not run on XP Pro SP1, Home and Win2000 SP4
    P pierrekande

    Dear Alex, Thank you for your reply to my request: In fact if you have the VC tools: "Dependency Walker", and if you have XP Pro SP2, if you open the ntdll.dll, you will see the following function that MS have added and that are not in version XP Pro SP2. "RtlIpv4AddressToStringA RtlIpv4AddressToStringExA RtlIpv4AddressToStringExW RtlIpv4AddressToStringW RtlIpv4StringToAddressA RtlIpv4StringToAddressExA RtlIpv4StringToAddressExW RtlIpv4StringToAddressW RtlIpv6AddressToStringA RtlIpv6AddressToStringExA RtlIpv6AddressToStringExW RtlIpv6AddressToStringW RtlIpv6StringToAddressA RtlIpv6StringToAddressExA RtlIpv6StringToAddressExW RtlIpv6StringToAddressW. So when I build my App, the linker use the ntdll.dll and call the function RtlIpv4AddressToStringW and RtlIpv6StringToAddressExW. and those function are not defined in the preview version of ntdll.dll. My version is: 5.1.2600.2180 The call to those function is made from WS2_32.dll (at version 5.1.2600.2180 to )that call it from ntdll.dll never try but make it.

    C / C++ / MFC announcement csharp visual-studio

  • Program compile witn XP Pro SP2 not run on XP Pro SP1, Home and Win2000 SP4
    P pierrekande

    Dear Sir, I have write a simple winsocket program on XP Pro SP2 with Visual studio net. 2003. All is fine. But when running the program on other machine like XP Pro SP1 or Win2000 Pro SP4 or on XP Home edition, my program does not run due to ntdll.dll (function RtlIpv6StringToAddressExW does not exist in preview version of ntdll.dll) And with the app dependency walker and can see the difference between those ntdll.dll. I do not need to update my other system to XP Pro SP2; What can I else do. Thank you in advanced. Pierre Kande

    C / C++ / MFC announcement csharp visual-studio

  • finding space in text file
    P pierrekande

    If your file is not so big, and if your project is link to MFC as shared lib, you can use the class CString to handle the text file. e.g. CString tmp(buffer); // where buffer contains data read from your file CString replaceString("myreplacestring"); while(tmp.Replace(" ",replaceString)); // Not all string like " " will be replace by "myreplacestring" and not " " THink this helps you

    C / C++ / MFC help c++ question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups