Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

vb.net Netzlaufwerk verbinden

Empfohlene Antworten

Veröffentlicht

hallo leute,

ich möchte mit vb.net ein netzlaufwerk verbinden. das ganze soll nicht mit:

shell("net use ....")
ablaufen, da ich das ganze in einem dienst einbauen will und ein shell-aufruf nicht möglich ist (soweit ich das probiert hab zumindest). als ansatz hab ich jetzt die API-Funktion WNetAddConnection2 probiert, was mir aber nicht wirklich funktioniert hat.
    Private Const RESOURCETYPE_DISK As Long = &H1


    Private Structure NETRESOURCE

        Dim dwScope As Long

        Dim dwType As Long

        Dim dwDisplayType As Long

        Dim dwUsage As Long

        Dim lpLocalName As String

        Dim lpRemoteName As String

        Dim lpComment As String

        Dim lpProvider As String

    End Structure


    'Deklaration: Globale Form API-Funktionen

    Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias _

    "WNetAddConnection2A" ( _

    ByVal lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal _

        lpUserName As String, _

        ByVal dwFlags As Long) As Long


    Private Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias _

    "WNetCancelConnection2A" ( _

        ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As _

        Long) As Long

    'Deklaration: Globale Form-Variablen

    Dim strUserName As String

    Dim strUserPassword As String


    Dim laufwerk As NETRESOURCE

und der aufruf

        laufwerk.lpRemoteName = "\\10.10.12.5\Software$"

        laufwerk.lpLocalName = "x:"

        laufwerk.dwType = RESOURCETYPE_DISK

        MsgBox(WNetAddConnection2(laufwerk, "<pw>", "<user>", 0))

zurückgeben tut er mir 487:confused: , womit ich nu mal garnix anfangen kann. weiß jemand was ich falsch mache, oder hat eine andere lösung netzlaufwerke zu verbinden?

danke

lg

jasso

zurückgeben tut er mir 487:confused: , womit ich nu mal garnix anfangen kann.

Die Fehlercodes kannst du in einer Commandozeile erfahren:

NET HELPMSG <Fehlercode>

487 --> "Es wurde versucht, auf eine unzulässige Adresse zuzugreifen.

  • Autor

die adresse hab ich aber manuell problemlos verbinden können.

habs mittlerweile anders umgangen.

aber wenn noch jemandem was dazu einfällt ... immer her damit.

lg

jasso

Der Fehler liegt in der API Deklaration.

deine:

Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias _

"WNetAddConnection2A" ( _

ByVal lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal _

lpUserName As String, _

ByVal dwFlags As Long) As Long

richtig :

Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias _

"WNetAddConnection2A" ( _

ByRef lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal _

lpUserName As String, _

ByVal dwFlags As Integer) As Integer

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.