Aufrufen von nicht verwaltetem Code aus .NET

Ich versuche, eine DLL in meinem C # -Programm zu verwenden, aber ich kann sie scheinbar nicht zum Laufen bringen. Ich habe eine unten gezeigte Test-App erstellt. Der Rückgabewert ist 0, tut jedoch nicht das, was es tun soll.

Wenn der folgende Befehl funktioniert:

rundll32 cmproxy.dll,SetProxy /source_filename proxy-1.txt /backup_filename roxy.bak /DialRasEntry NULL /TunnelRasEntry DSLVPN /Profile "C:\Documents and ettings\Administrator\Application Data\Microsoft\Network\Connections\Cm\dslvpn.cmp"

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Net;
using WUApiLib;

namespace nac
{
    class Program
    {
        [DllImport("cmproxy.dll", CharSet = CharSet.Unicode)]
        static extern int SetProxy(string cmdLine);

        static void Main(string[] args)
        {
            string cmdLine = @"/source_filename proxy-1.txt /backup_filename proxy.bak /DialRasEntry NULL /TunnelRasEntry DSLVPN /Profile ""C:\Documents and Settings\Administrator\Application Data\Microsoft\Network\Connections\Cm\dslvpn.cmp""";
            Console.WriteLine(SetProxy(cmdLine));
        }
    }
}

Hier ist der Inhalt des Befehls dumpbin / exports

File Type: DLL

  Section contains the following exports for cmproxy.dll

    00000000 characteristics
    3E7FEF8C time date stamp Tue Mar 25 05:56:28 2003
        0.00 version
           1 ordinal base
           1 number of functions
           1 number of names

    ordinal hint RVA      name

          1    0 00001B68 SetProxy

  Summary

        1000 .data
        1000 .reloc
        1000 .rsrc
        2000 .text

Wenn dies funktioniert, wird der Proxy-Server für eine VPN-Verbindung eingerichtet.

BEARBEITEN

Ich möchte vermeiden, rundll32 von system.process aus auszuführen

Ich kann auch einen Link zur DLL und zu meiner Test-App bereitstellen. Obwohl der oben eingefügte Code alles ist, was er enthält, und die DLL aus dem Server Resource Kit verfügbar ist, denke ich.

AKTUALISIEREN

Ich habe eine Test-DLL in c ++ geschrieben, die einfach die Argumente wiedergibt, die sie enthält. Es läuft, aber es heißt

Der Verweis ist ungülti

Antworten auf die Frage(3)

Ihre Antwort auf die Frage