PfCreateInterface(...) Return 120

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EngAhmadSlo
    New Member
    • Apr 2010
    • 7

    #1

    PfCreateInterface(...) Return 120

    I Use Vista .
    When I call PfCreateInterfa ce(...) It Return error 120.
    Can any body help me?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    PfCreateInterfa ce is your method in your program. Right?
    How would anyone here know what it does?

    Comment

    • EngAhmadSlo
      New Member
      • Apr 2010
      • 7

      #3
      PfCraeteInterfa ce(...) exists in Iphlpapi.dll that exists in system32
      it isn't my method .
      so can any body help me?
      please...

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        This is covered on MSDN.
        Have you gone through the MSDN write up?
        http://msdn.microsoft.com/en-us/libr...73(VS.85).aspx

        IP Helper is designed for C/C++ coding. You posted in the C# area. Which language are you trying to code in?

        pfCreaterInterf ace() isn't even listed in the API functions. Have you worked through the tutorials and built the sample application first, just to get an understanding of the API? Or are you trying to apply this dll to your own application by just guessing and stabbing at it?

        Comment

        • EngAhmadSlo
          New Member
          • Apr 2010
          • 7

          #5
          I write this code
          Code:
          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Text;
          namespace firewall
          {
              class Program
              {
          
                  static void Main(string[] args)
                  {
                      IntPtr ppInterface=new IntPtr();
                      int Result=PfCreateInterface(0,0,0,true,true ,ref ppInterface );
                      Console.WriteLine(Result.ToString());
                      Console.ReadKey();
                  }
                  [System.Runtime.InteropServices.DllImport("iphlpapi.dll")]
                  public static extern int PfCreateInterface( uint dwName,
                                                              uint inAction,
                                                              uint outAction,
                                                              bool bUseLog,
                                                              bool bMustBeUnique,
                                                             ref  IntPtr ppInterface );
          
              }
          }
          when I try this code with XP the Output was "0" that mean NO_ERROR
          but With Vista and 7 the Output was "120" that mean there is an error

          please, Tell me if the code Work on Vista Or 7

          Comment

          • tlhintoq
            Recognized Expert Specialist
            • Mar 2008
            • 3532

            #6
            IP Helper is designed to be used from C and C++. It was not designed for C#, as you are using it.

            With that said, you might be able to get away with importing commands as you have done. But at the very least you need to limit what you try to do to the commands that are published as available. And "CreateInterfac e" is not one of them.
            http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx

            Most of us at one time or another have probably used code in a way not designed by the publisher. I know I have. But the results can be unpredictable.

            If you want to know if something undocumented and untested will work in a new operating system then you will need to do your own testing.

            Comment

            Working...