Windows Vista Forums

Vb6 Convert
  1. #1


    Phil Hunt Guest

    Vb6 Convert

    Hi
    Can you help me with converting a VB6 Declare Function construct to C#
    systax. I think it is in the form of



    [DLLImport ("A.DLL")]
    public extrn void someFunction(.....);

    But I don't see the association between the 2 statements. Can someone
    explain ?

    THanks



      My System SpecsSystem Spec

  2. #2


    Nicholas Paldino [.NET/C# MVP] Guest

    Re: Vb6 Convert

    Phil,

    Well, the DllImport attribute tells the CLR what the name of the DLL is
    to load to find the function in (as well as other information, like the .
    The CLR will then use function information to figure out the signature of
    the function and load it from the dll, and subsequently call it.

    The "extern" keyword here, combined with the attribute indicates that
    the function is found in an unmanaged DLL (there should be a static keyword
    here as well).


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@xxxxxx

    "Phil Hunt" <aaa@xxxxxx> wrote in message
    news:%23r$DHm2PJHA.4424@xxxxxx

    > Hi
    > Can you help me with converting a VB6 Declare Function construct to C#
    > systax. I think it is in the form of
    >
    > [DLLImport ("A.DLL")]
    > public extrn void someFunction(.....);
    >
    > But I don't see the association between the 2 statements. Can someone
    > explain ?
    >
    > THanks
    >


      My System SpecsSystem Spec

  3. #3


    Phil Hunt Guest

    Re: Vb6 Convert

    The dll i have that has many entry point. It seems like I have to repeat the
    Import statement everytime I declare a different function. Is that a short
    hand for that. Also in VB6 the Declare stmt associate the fucntion with the
    dll. Can I do that in this contruct ?

    Thanks again


    "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxx> wrote in
    message news:OUdnZz2PJHA.3932@xxxxxx

    > Phil,
    >
    > Well, the DllImport attribute tells the CLR what the name of the DLL is
    > to load to find the function in (as well as other information, like the .
    > The CLR will then use function information to figure out the signature of
    > the function and load it from the dll, and subsequently call it.
    >
    > The "extern" keyword here, combined with the attribute indicates that
    > the function is found in an unmanaged DLL (there should be a static
    > keyword here as well).
    >
    >
    > --
    > - Nicholas Paldino [.NET/C# MVP]
    > - mvp@xxxxxx
    >
    > "Phil Hunt" <aaa@xxxxxx> wrote in message
    > news:%23r$DHm2PJHA.4424@xxxxxx

    >> Hi
    >> Can you help me with converting a VB6 Declare Function construct to C#
    >> systax. I think it is in the form of
    >>
    >> [DLLImport ("A.DLL")]
    >> public extrn void someFunction(.....);
    >>
    >> But I don't see the association between the 2 statements. Can someone
    >> explain ?
    >>
    >> THanks
    >>
    >
    >


      My System SpecsSystem Spec

  4. #4


    Nicholas Paldino [.NET/C# MVP] Guest

    Re: Vb6 Convert

    Phil,

    Yes, you are right, you have to make a new declaration for each function
    that you want to use through the P/Invoke layer.

    There is no shorthand for that, AFAIK.

    The DllImport attribute is what associates the function declaration with
    the DLL that it is located in. You have to repeat this for every
    declaration as well.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@xxxxxx

    "Phil Hunt" <aaa@xxxxxx> wrote in message
    news:eHMj9O3PJHA.3932@xxxxxx

    > The dll i have that has many entry point. It seems like I have to repeat
    > the Import statement everytime I declare a different function. Is that a
    > short hand for that. Also in VB6 the Declare stmt associate the fucntion
    > with the dll. Can I do that in this contruct ?
    >
    > Thanks again
    >
    >
    > "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxx> wrote
    > in message news:OUdnZz2PJHA.3932@xxxxxx

    >> Phil,
    >>
    >> Well, the DllImport attribute tells the CLR what the name of the DLL
    >> is to load to find the function in (as well as other information, like
    >> the . The CLR will then use function information to figure out the
    >> signature of the function and load it from the dll, and subsequently call
    >> it.
    >>
    >> The "extern" keyword here, combined with the attribute indicates that
    >> the function is found in an unmanaged DLL (there should be a static
    >> keyword here as well).
    >>
    >>
    >> --
    >> - Nicholas Paldino [.NET/C# MVP]
    >> - mvp@xxxxxx
    >>
    >> "Phil Hunt" <aaa@xxxxxx> wrote in message
    >> news:%23r$DHm2PJHA.4424@xxxxxx

    >>> Hi
    >>> Can you help me with converting a VB6 Declare Function construct to C#
    >>> systax. I think it is in the form of
    >>>
    >>> [DLLImport ("A.DLL")]
    >>> public extrn void someFunction(.....);
    >>>
    >>> But I don't see the association between the 2 statements. Can someone
    >>> explain ?
    >>>
    >>> THanks
    >>>
    >>
    >>
    >
    >


      My System SpecsSystem Spec

  5. #5


    Phil Hunt Guest

    Re: Vb6 Convert

    Thanks for your help.

    "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxx> wrote in
    message news:udZi6T3PJHA.4224@xxxxxx

    > Phil,
    >
    > Yes, you are right, you have to make a new declaration for each
    > function that you want to use through the P/Invoke layer.
    >
    > There is no shorthand for that, AFAIK.
    >
    > The DllImport attribute is what associates the function declaration
    > with the DLL that it is located in. You have to repeat this for every
    > declaration as well.
    >
    >
    > --
    > - Nicholas Paldino [.NET/C# MVP]
    > - mvp@xxxxxx
    >
    > "Phil Hunt" <aaa@xxxxxx> wrote in message
    > news:eHMj9O3PJHA.3932@xxxxxx

    >> The dll i have that has many entry point. It seems like I have to repeat
    >> the Import statement everytime I declare a different function. Is that a
    >> short hand for that. Also in VB6 the Declare stmt associate the fucntion
    >> with the dll. Can I do that in this contruct ?
    >>
    >> Thanks again
    >>
    >>
    >> "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxx> wrote
    >> in message news:OUdnZz2PJHA.3932@xxxxxx

    >>> Phil,
    >>>
    >>> Well, the DllImport attribute tells the CLR what the name of the DLL
    >>> is to load to find the function in (as well as other information, like
    >>> the . The CLR will then use function information to figure out the
    >>> signature of the function and load it from the dll, and subsequently
    >>> call it.
    >>>
    >>> The "extern" keyword here, combined with the attribute indicates that
    >>> the function is found in an unmanaged DLL (there should be a static
    >>> keyword here as well).
    >>>
    >>>
    >>> --
    >>> - Nicholas Paldino [.NET/C# MVP]
    >>> - mvp@xxxxxx
    >>>
    >>> "Phil Hunt" <aaa@xxxxxx> wrote in message
    >>> news:%23r$DHm2PJHA.4424@xxxxxx
    >>>> Hi
    >>>> Can you help me with converting a VB6 Declare Function construct to C#
    >>>> systax. I think it is in the form of
    >>>>
    >>>> [DLLImport ("A.DLL")]
    >>>> public extrn void someFunction(.....);
    >>>>
    >>>> But I don't see the association between the 2 statements. Can someone
    >>>> explain ?
    >>>>
    >>>> THanks
    >>>>
    >>>
    >>>
    >>
    >>
    >
    >


      My System SpecsSystem Spec

Vb6 Convert problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
convert vhs to Dvd yohbits Chillout Room 7 09 Oct 2008
RE: Convert VHD to ISO? Musthafa Virtual PC 0 06 Sep 2008
convert wav to mp3 and mp3 to wav mediaplayerasker Vista music pictures video 4 14 Feb 2008
How to convert MP3 to WMA? Lance Vista music pictures video 10 14 Jul 2007
Convert EML to DBX? Danny Vista mail 10 05 Feb 2007