home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD52564272000.psc / modMain.bas < prev   
Encoding:
BASIC Source File  |  2000-04-21  |  2.1 KB  |  60 lines

  1. Attribute VB_Name = "modMain"
  2. Option Explicit
  3.  
  4. Public Const email = "Marco.Sambento@netc.pt?subject="
  5. Public Const SW_SHOWNORMAL = 1
  6. Dim WordPad As String
  7. Global WinDir As String
  8.  
  9. Private Declare Function GetWindowsDirectory Lib "kernel32.dll" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  10. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  11.  
  12. Sub Main()
  13.     GetWinDir
  14.     frmMain.Show
  15. End Sub
  16.  
  17. Function GetWinDir()
  18.  
  19. Dim WinDirectory As String  ' receives path of Windows directory
  20. Dim slength As Long  ' receives length of the string returned
  21.  
  22. WinDirectory = Space(255)  ' initialize buffer to receive the string
  23. slength = GetWindowsDirectory(WinDirectory, 255)  ' read the path of the Windows directory
  24. WinDir = Left(WinDirectory, slength)  ' extract the returned string from the buffer
  25.  
  26. End Function
  27.  
  28. Function WordPadPath()
  29.     Dim Button As VbMsgBoxResult
  30.     Dim retval As String
  31.     Dim Result As Integer
  32.     
  33.     retval = String$(255, 0)
  34.     Result = GetPrivateProfileString("programs", "wordpad.exe", "Not Found", retval, Len(retval), WinDir & "\win.ini")
  35.     
  36.     If Result <> 0 Then
  37.         WordPad = Left(retval, InStr(retval, vbNullChar) - 1)
  38.     End If
  39. End Function
  40.  
  41. Public Function OpenWordPad()
  42.     Dim Button As VbMsgBoxResult
  43.     Dim Result As Integer
  44.     
  45. If WordPad = vbNullString Then Call WordPadPath
  46. If WordPad = "Not Found" Then
  47.     Button = MsgBox("WordPad not Found!" & vbLf & "Try opening in notepad?", vbCritical + vbYesNo)
  48.     If Button = vbYes Then WordPad = "notepad" Else Exit Function
  49. End If
  50.  
  51. Result = ShellExecute(0&, "open", WordPad, """" & INIPath & """", vbNullString, vbMaximizedFocus) '
  52. 'here you can check if it was successfully executed
  53.  
  54. End Function
  55.  
  56. Public Sub SendEmail()
  57. Dim Success As Long
  58. Success = ShellExecute(0&, vbNullString, "mailto:" & email & App.Title, vbNullString, "C:\", SW_SHOWNORMAL)
  59. End Sub
  60.