Projektdateien hinzufügen.

This commit is contained in:
2024-05-27 11:07:32 +02:00
parent b6bdcf9b1f
commit b2efa36fe1
24 changed files with 1671 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
Imports Microsoft.VisualBasic.ApplicationServices
Namespace My
' The following events are available for MyApplication:
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
' **NEW** ApplyApplicationDefaults: Raised when the application queries default values to be set for the application.
' Example:
' Private Sub MyApplication_ApplyApplicationDefaults(sender As Object, e As ApplyApplicationDefaultsEventArgs) Handles Me.ApplyApplicationDefaults
'
' ' Setting the application-wide default Font:
' e.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular)
'
' ' Setting the HighDpiMode for the Application:
' e.HighDpiMode = HighDpiMode.PerMonitorV2
'
' ' If a splash dialog is used, this sets the minimum display time:
' e.MinimumSplashScreenDisplayTime = 4000
' End Sub
Partial Friend Class MyApplication
End Class
End Namespace

View File

@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<StartupObject>Sub Main</StartupObject>
<UseWindowsForms>true</UseWindowsForms>
<MyType>WindowsForms</MyType>
</PropertyGroup>
<ItemGroup>
<Import Include="System.Data" />
<Import Include="System.Drawing" />
<Import Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Update="My Project\Application.Designer.vb">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
</Project>

98
Connect_Netzlaufwerk/Form1.Designer.vb generated Normal file
View File

@@ -0,0 +1,98 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
lblConnect = New Label()
lblDriveCaption = New Label()
ComboDrive = New ComboBox()
Button1 = New Button()
Button2 = New Button()
SuspendLayout()
'
' lblConnect
'
lblConnect.AutoSize = True
lblConnect.Location = New Point(25, 19)
lblConnect.Name = "lblConnect"
lblConnect.Size = New Size(41, 15)
lblConnect.TabIndex = 0
lblConnect.Text = "Label1"
'
' lblDriveCaption
'
lblDriveCaption.AutoSize = True
lblDriveCaption.Location = New Point(25, 52)
lblDriveCaption.Name = "lblDriveCaption"
lblDriveCaption.Size = New Size(41, 15)
lblDriveCaption.TabIndex = 1
lblDriveCaption.Text = "Label1"
'
' ComboDrive
'
ComboDrive.FormattingEnabled = True
ComboDrive.Location = New Point(121, 52)
ComboDrive.Name = "ComboDrive"
ComboDrive.Size = New Size(121, 23)
ComboDrive.TabIndex = 2
'
' Button1
'
Button1.Location = New Point(25, 100)
Button1.Name = "Button1"
Button1.Size = New Size(75, 23)
Button1.TabIndex = 3
Button1.Text = "Connect"
Button1.UseVisualStyleBackColor = True
'
' Button2
'
Button2.Location = New Point(121, 100)
Button2.Name = "Button2"
Button2.Size = New Size(75, 23)
Button2.TabIndex = 4
Button2.Text = "Disconnect"
Button2.UseVisualStyleBackColor = True
'
' Form1
'
AutoScaleDimensions = New SizeF(7F, 15F)
AutoScaleMode = AutoScaleMode.Font
ClientSize = New Size(800, 450)
Controls.Add(Button2)
Controls.Add(Button1)
Controls.Add(ComboDrive)
Controls.Add(lblDriveCaption)
Controls.Add(lblConnect)
Name = "Form1"
Text = "Form1"
ResumeLayout(False)
PerformLayout()
End Sub
Friend WithEvents lblConnect As Label
Friend WithEvents lblDriveCaption As Label
Friend WithEvents ComboDrive As ComboBox
Friend WithEvents Button1 As Button
Friend WithEvents Button2 As Button
End Class

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,124 @@
Imports System.IO
Public Class Form1
Dim strUserName As String ' UserName für Anmelden beim Netzlaufwerk
Dim strUserPassword As String ' Password für die Anmeldung
Dim strDrive As String ' Laufwerksbuchstabe
' Dieser Source stammt von http://www.activevb.de
' und kann frei verwendet werden. Für eventuelle Schäden
' wird nicht gehaftet.
' Um Fehler oder Fragen zu klären, nutzen Sie bitte unser Forum.
' Ansonsten viel Spaß und Erfolg mit diesem Source !
' Deklaration: Globale Form API-Konstanten
' Private Const RESOURCETYPE_DISK As Int32 = &H1
Const RESOURCETYPE_DISK = &H1
' Deklaration: Globale Form API-Typen
Public Structure NETRESOURCE
Public dwScope As Integer
Public dwType As Integer
Public dwDisplayType As Integer
Public dwUsage As Integer
Public lpLocalName As String
Public lpRemoteName As String
Public lpComment As String
Public lpProvider As String
End Structure
' Deklaration: Globale Form API-Funktionen
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
Private Declare Function WNetCancelConnection2 Lib "mpr.dll" _
Alias "WNetCancelConnection2A" (
ByVal lpName As String,
ByVal dwFlags As Integer,
ByVal fForce As Integer) As Integer
Dim udtNetzResource As NETRESOURCE
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
lblConnect.Text = "Es ist keine Verbindung hergestellt."
' Freien Laufwerks-Buchstaben ermitteln
Dim i As Integer
Dim sDrives As String = Join(Directory.GetLogicalDrives(), "")
Dim sNextDrive As String = ""
For i = 68 To 90
If Not sDrives.Contains(Chr(i) & ":") Then
sNextDrive = Chr(i) & ":"
ComboDrive.Items.Add(sNextDrive)
End If
Next
' R1 = Rechnername, C_SYSTEM = Name des zuzuweisenden Laufwerks
udtNetzResource.lpRemoteName = "\\SDD-VMP03-VM09\DataFiles$\Digital Data\EnvelopeGenerator\EnvelopeGeneratorExport"
' Username & Passwort (anhängig vom Freigabestatus des Laufwerks). Inhalt ist
' bestenfalls egal
strUserName = "dd-san01\Administrator"
strUserPassword = "##25!45!3_works"
udtNetzResource.dwType = RESOURCETYPE_DISK
lblDriveCaption.Text = ""
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Abfrage ob ein Laufwerksbuchstabe ausgewählt wurde
If ComboDrive.Text = "" Then
MsgBox("Es wurde kein freier Laufwerks-Buchstabe ausgewählt.")
Else
' gewählter Laufwerksbuchstabe sichern für die Trennung
strDrive = ComboDrive.Text
udtNetzResource.lpLocalName = ComboDrive.Text
Dim lngResult As Integer
' Hier wird verbunden
' dwFlag muss 1 sein
lngResult = WNetAddConnection2(udtNetzResource, strUserPassword, strUserName, 1)
If lngResult = 0 Then
lblConnect.Text = "Verbunden."
Else
lblConnect.Text = "Verbindung nicht möglich."
End If
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
' gewählter Laufwerksbuchstabe sichern für die Trennung
strDrive = ComboDrive.Text
udtNetzResource.lpLocalName = ComboDrive.Text
Dim lngResult As Integer
lngResult = WNetCancelConnection2(strDrive, 0, True)
If lngResult = 0 Then
lblConnect.Text = "Getrennt."
Else
lblConnect.Text = "Trennung nicht möglich."
End If
End Sub
End Class

View File

@@ -0,0 +1,37 @@
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' or if you encounter build errors in this file, go to the Project Designer
' (go to Project Properties or double-click the My Project node in
' Solution Explorer), and make changes on the Application tab.
'
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()>
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = False
Me.EnableVisualStyles = True
Me.SaveMySettingsOnExit = True
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()>
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Form1
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain>
<MainForm>Form1</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>