1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
Imports System.IO
Imports Microsoft.VisualBasic
Module modManifest
''' <summary>
'''
''' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
'''
''' STEITZ® IT-Solutions
'''
''' Diese Funktion erstellt eine Manifestdatei welche unter Windows Vista™
''' erhöhte Rechte beim Betriebssystem abfordert. Es wird - beim Anwendungs-
''' start gefragt, ob die Anwendung ausfgeführt werden darf.
'''
''' Ist die Manifestdatei beim ersten Programmstart nicht vorhanden, wird
''' sie sofort erstellt. Gleiches gilt auch, wenn Sie gelöscht wurde.
'''
''' Beim 2. Start der Anwendung werden dann die entsprechenden Rechte
''' abgefragt.
'''
'''
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Function Manifest() As String
If File.Exists(Application.StartupPath & "\" & Application.ProductName & ".exe.manifest") = True Then
Return Nothing
Exit Function
Else
Dim ManifestContent As String = String.Empty
Dim nl As String = vbCrLf
ManifestContent = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" & nl
ManifestContent &= "<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>" & nl
ManifestContent &= "<!-- Identify the application security requirements. -->" & nl
ManifestContent &= "<trustInfo xmlns=" & """" & "urn:schemas-microsoft-com:asm.v2" & """" & ">" & nl
ManifestContent &= "<security>" & nl
ManifestContent &= "<requestedPrivileges>" & nl
ManifestContent &= " <requestedExecutionLevel" & nl
ManifestContent &= " level=" & """" & "requireAdministrator" & """" & " uiAccess=" & """" & "false" & """" & "/>" & nl
ManifestContent &= "</requestedPrivileges>" & nl
ManifestContent &= "</security>" & nl
ManifestContent &= "</trustInfo>" & nl
ManifestContent &= "</assembly>" & nl
'Manifestdatei erstellen
Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\" & Application.ProductName & ".exe.manifest")
sw.Write(ManifestContent)
sw.Close()
MessageBox.Show(createdText, "", MessageBoxButtons.OK, MessageBoxIcon.Information)
GC.Collect()
End
Return Nothing
End If
End Function
Private createdText As String = _
"Es wurde eine neue Manifestdatei erstellt. Damit die Anwendung ordnungsgemaess arbeitet" & _
"muss sie neu gestartet werden." & vbCrLf & vbCrLf & _
"Nachdem Sie diese Meldung mit ""ok"" bestaetigt habe, wird sie beendet werden." & vbCrLf & _
"Bitte starten Sie sie anschließend durch einen Doppelclick auf das Anwendungssymbol"
End Module
|