Sendkeys error 70 permission denied in vb 6.0 on Windows 7 and above Versions
Solution 1 :
your UAC worked for SENDKEY problem in VB on windows 2007 platform. if your turn off your UAC you should be able to use that function.
if your UAC is off , then Turn it on again , Then , Turn it off again .... and RESTART your PC ....
and make sure of using "Run as administrator " ....
Solution 2 :
Code:
Public Sub Sendkeys(text$, Optional wait As Boolean = False)
Dim WshShell As Object
Set WshShell = CreateObject("wscript.shell")
WshShell.Sendkeys text, wait
Set WshShell = Nothing
End Sub
Code:
Public Sub Sendkeys(text$, Optional wait As Boolean = False)
Dim WshShell As Object
Set WshShell = CreateObject("wscript.shell")
WshShell.Sendkeys text, wait
Set WshShell = Nothing
End Sub
VB6 - Cannot initiate data bindings Error
Microsoft Data Grid Control - Cannot initiate data bindings.
This error occurred when Microsoft Office not install or uninstall
Solution
You may be missing a key file "MSSTDFMT.DLL" download or copy the file in to your System folder or System32 folder (XP). Click Start, select Run, Key in Regsvr32 C:\Windows\System\msstdfmt.dll
You may be missing a key file "MSSTDFMT.DLL" download or copy the file in to your System folder or System32 folder (XP). Click Start, select Run, Key in Regsvr32 C:\Windows\System\msstdfmt.dll
Find Windows Version Name And Number from Vb6.0
Open Vb form & get one command button, one text box Array named as Text1(0) ,one label array named Label1(0) . After that copy and paste below code. Try it.
Vb Code
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Const VER_PLATFORM_WIN32s = 0
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2
'windows-defined type OSVERSIONINFO
Private Type OSVERSIONINFO
OSVSize As Long 'size, in bytes, of this data structure
dwVerMajor As Long 'ie NT 3.51, dwVerMajor = 3; NT 4.0, dwVerMajor = 4.
dwVerMinor As Long 'ie NT 3.51, dwVerMinor = 51; NT 4.0, dwVerMinor= 0.
dwBuildNumber As Long 'NT: build number of the OS
'Win9x: build number of the OS in low-order word.
' High-order word contains major & minor ver nos.
PlatformID As Long 'Identifies the operating system platform.
szCSDVersion As String * 128 'NT: string, such as "Service Pack 3"
'Win9x: 'arbitrary additional information'
End Type
'my type for holding the retrieved info
Private Type RGB_WINVER
PlatformID As Long
VersionName As String
VersionNo As String
ServicePack As String
BuildNo As String
End Type
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
Private Sub Form_Load()
Dim cnt As Long
Dim TotalRequired As Long
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
'the array is 0-based, so the first control is
'index 0, and the last is TotalRequired -1
TotalRequired = 13
For cnt = 0 To TotalRequired - 1
'since Text1(0) already exists, we don't load it
If cnt > 0 Then
Load Label1(cnt)
Load Text1(cnt)
End If
'position the newly-created control
Label1(cnt).Move 120, 230 + (cnt * 300)
Text1(cnt).Move 1600, 200 + (cnt * 300), 3900, 285
'and show
Label1(cnt).Visible = True
Text1(cnt).Visible = True
Next
With Label1
.Item(0).Caption = "Windows version"
.Item(1).Caption = "Version number"
.Item(2).Caption = "Build number"
.Item(3).Caption = "Service Pack/misc"
.Item(4).Caption = "Platform identifier"
.Item(5).Caption = "Together"
.Item(6).Caption = "IsWin95 returns"
.Item(7).Caption = "IsWin98 returns"
.Item(8).Caption = "IsWinME returns"
.Item(9).Caption = "IsWinNT4 returns"
.Item(10).Caption = "IsWin2000 returns"
.Item(11).Caption = "IsWinXP returns"
.Item(12).Caption = "GetWinVer returns"
End With
End Sub
Private Sub Command1_Click()
Dim win As RGB_WINVER
Call GetWinVersion(win)
Text1(0).Text = win.VersionName
Text1(1).Text = win.VersionNo
Text1(2).Text = win.BuildNo
Text1(3).Text = win.ServicePack
Text1(4).Text = win.PlatformID
'as a version string
Text1(5).Text = win.VersionName & " " & _
win.VersionNo & " build " & _
win.BuildNo & " (" & _
win.ServicePack & ")"
Text1(6).Text = IsWin95()
Text1(7).Text = IsWin98()
Text1(8).Text = IsWinME()
Text1(9).Text = IsWinNT4()
Text1(10).Text = IsWin2000()
Text1(11).Text = IsWinXP()
Text1(12).Text = GetWinVer()
End Sub
Private Function GetWinVersion(win As RGB_WINVER) As String
'returns a structure (RGB_WINVER)
'filled with OS information
#If Win32 Then
Dim osv As OSVERSIONINFO
Dim pos As Integer
Dim sVer As String
Dim sBuild As String
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
'PlatformId contains a value representing the OS
win.PlatformID = osv.PlatformID
Select Case osv.PlatformID
Case VER_PLATFORM_WIN32s: win.VersionName = "Win32s"
Case VER_PLATFORM_WIN32_NT: win.VersionName = "Windows NT"
Select Case osv.dwVerMajor
Case 4: win.VersionName = "Windows NT"
Case 5: win.VersionName = "Windows Server 2003"
Select Case osv.dwVerMinor
Case 0: win.VersionName = "Windows 2000"
Case 1: win.VersionName = "Windows XP"
End Select
Case 6: win.VersionName = "Windows 7"
End Select
Case VER_PLATFORM_WIN32_WINDOWS:
'The dwVerMinor bit tells if its 95 or 98.
Select Case osv.dwVerMinor
Case 0: win.VersionName = "Windows 95"
Case 90: win.VersionName = "Windows ME"
Case Else: win.VersionName = "Windows 98"
End Select
End Select
'Get the version number
win.VersionNo = osv.dwVerMajor & "." & osv.dwVerMinor
'Get the build
win.BuildNo = (osv.dwBuildNumber And &HFFFF&)
'Any additional info. In Win9x, this can be
'"any arbitrary string" provided by the
'manufacturer. In NT, this is the service pack.
pos = InStr(osv.szCSDVersion, Chr$(0))
If pos Then
win.ServicePack = Left$(osv.szCSDVersion, pos - 1)
End If
End If
#Else
'can only return that this does not
'support the 32 bit call, so must be Win3x
win.VersionName = "Windows 3.x"
#End If
End Function
Private Function IsWin95() As Boolean
'returns True if running Win95
#If Win32 Then
Dim osv As OSVERSIONINFO
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
IsWin95 = (osv.PlatformID = VER_PLATFORM_WIN32_WINDOWS) And _
(osv.dwVerMajor = 4 And osv.dwVerMinor = 0)
End If
#End If
End Function
Private Function IsWin98() As Boolean
'returns True if running Win98
Dim osv As OSVERSIONINFO
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
IsWin98 = (osv.PlatformID = VER_PLATFORM_WIN32_WINDOWS) And _
(osv.dwVerMajor = 4 And osv.dwVerMinor = 10) And _
(osv.dwBuildNumber >= 2222)
End If
End Function
Private Function IsWinME() As Boolean
'returns True if running Windows ME
#If Win32 Then
Dim osv As OSVERSIONINFO
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
IsWinME = (osv.PlatformID = VER_PLATFORM_WIN32_WINDOWS) And _
(osv.dwVerMajor = 4 And osv.dwVerMinor = 90)
End If
#End If
End Function
Private Function IsWinNT4() As Boolean
'returns True if running WinNT4
#If Win32 Then
Dim osv As OSVERSIONINFO
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
'PlatformId contains a value representing the OS.
'If VER_PLATFORM_WIN32_NT and dwVerMajor is 4, return true
IsWinNT4 = (osv.PlatformID = VER_PLATFORM_WIN32_NT) And _
(osv.dwVerMajor = 4)
End If
#End If
End Function
Private Function IsWin2000() As Boolean
'returns True if running Windows 2000 (NT5)
#If Win32 Then
Dim osv As OSVERSIONINFO
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
IsWin2000 = (osv.PlatformID = VER_PLATFORM_WIN32_NT) And _
(osv.dwVerMajor = 5 And osv.dwVerMinor = 0)
End If
#End If
End Function
Private Function IsWinXP() As Boolean
'returns True if running WinXP (NT5.1)
#If Win32 Then
Dim osv As OSVERSIONINFO
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
IsWinXP = (osv.PlatformID = VER_PLATFORM_WIN32_NT) And _
(osv.dwVerMajor = 5 And osv.dwVerMinor = 1)
End If
#End If
End Function
Private Function GetWinVer() As String
'returns a string representing the version,
'ie "95", "98", "NT4", "WinXP"
Dim osv As OSVERSIONINFO
Dim r As Long
Dim pos As Integer
Dim sVer As String
Dim sBuild As String
osv.OSVSize = Len(osv)
If GetVersionEx(osv) = 1 Then
'PlatformId contains a value representing the OS
Select Case osv.PlatformID
Case VER_PLATFORM_WIN32s: GetWinVer = "32s"
Case VER_PLATFORM_WIN32_NT:
'dwVerMajor = NT version.
'dwVerMinor = minor version
Select Case osv.dwVerMajor
Case 3:
Select Case osv.dwVerMinor
Case 0: GetWinVer = "NT3"
Case 1: GetWinVer = "NT3.1"
Case 5: GetWinVer = "NT3.5"
Case 51: GetWinVer = "NT3.51"
End Select
Case 4: GetWinVer = "NT 4"
Case 5:
Select Case osv.dwVerMinor
Case 0: GetWinVer = "Win2000"
Case 1: GetWinVer = "WinXP"
End Select
End Select
Case VER_PLATFORM_WIN32_WINDOWS:
'dwVerMinor bit tells if its 95 or 98.
Select Case osv.dwVerMinor
Case 0: GetWinVer = "95"
Case 90: GetWinVer = "ME"
Case Else: GetWinVer = "98"
End Select
End Select
End If
End Function
How to set system default printer in Visual Basic 6
VB Code:
call setPrinter("PrinterName")
Private Sub setPrinter(Name As String) Dim prThis As Printer If Printers.Count > 0 Then For Each prThis In Printers If prThis.DeviceName = Name Then Set Printer = prThis Exit For End If Next prThis End If End Sub
No comments:
Post a Comment