Re: Selectively disallowing PInvoke

From: Geoff Schwab [MSFT] (a-geosch_at_online.microsoft.com)
Date: 11/17/03


Date: Mon, 17 Nov 2003 11:24:51 -0800

Hi Nandakumar,

I assume you want this control from the managed side of the code. Can you
get enough control by using namespaces combined with internal? I do
something similar in a graphics engine by doing the following...

namespace GXGraphicsLibrary
{
    // This is only available internal to GXGraphicsLibrary
    internal class GAPI
    {
        [DllImport("gx.dll", EntryPoint="#1")]
        extern public static IntPtr GxBeginDraw();
    }

    // This is visible to anyone accessing GXGraphicsLibrary
    public class Windows
    {
        [DllImport("coredll.dll")]
        extern public static IntPtr GetCapture();
    }
}

You should also be able to control each P/Invoke individually using internal
where I have the declarations as public, though I have not tried this...

namespace GXGraphicsLibrary
{
    public class Imports
    {
        // This is only available internal to GXGraphicsLibrary
        [DllImport("gx.dll", EntryPoint="#1")]
        extern internal static IntPtr GxBeginDraw();

        // This is visible to anyone accessing GXGraphicsLibrary
        [DllImport("coredll.dll")]
        extern public static IntPtr GetCapture();
    }
}

-- 
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
"Nandakumar Sankaran" <Nandakumar@bsquare.com> wrote in message
news:uA0k5WwqDHA.2244@TK2MSFTNGP12.phx.gbl...
> Hi, I'm wondering if there is a way in a Windows CE.Net environment to
> selectively permit managed applications to call into native DLLs (through
> PInvoke). In other words, I want to allow certain applications to be able
to
> call into native DLLs and disallow other apps from doing the same.
>
> Thanks for any suggestions.
> Nandakumar
>
>


Relevant Pages

  • Re: Referencing a Generic
    ... > public class Pager: Control ... > I'm getting an error message that says, "The type or namespace name 'T' ... public class Pager: Control ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why null reference to ListBox?
    ... I'm not sure what NameSpace means here. ... Search for Listbox ... Given that I dragged a graphical representation of a control from a ... sub aaaa ...
    (microsoft.public.excel.programming)
  • Re: Prob using a custom type in asp.net webservice
    ... I tried both of your suggestions and the autogenerated webref proxy types ... continue to define a namespace attrib. ... public class Class1 ... the webreference proxy no longer works. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: java heap space
    ... public class Gui_Start extends JFrame ... Gui_Start(Control control) ... private void button_personalActionPerformed{ ... will repost your code as an SSCCE*. ...
    (comp.lang.java.programmer)
  • Re: XmlSerializer
    ... XmlSerializerNamespaces emptyNamespace = new XmlSerializerNamespaces; ... //Serialize the array, using the empty namespace ... > public class FormField { ... > public FormField(string Name, string Value) { ...
    (microsoft.public.dotnet.xml)