Prikazi cijelu temu 19.06.2011 12:39
roko Van mreze
Clan
Registrovan od:02.02.2009
Lokacija:Rijeka


Predmet:MDE , ACCDE to EXE
Kako se neki ( ? ? pametni) bune zaÅ¡to im se distribuira access app evo postavljam način kako da se napravi distribucija kvazi exe app. Koristio sam VB6 portable.
Osim što se formira exe Files App i ažuriria \Access\Security\Trusted Locations zbog sigurnosne lokacije i (trebalo bi ) radi sa runtime access koji je instaliran na mašini
1.Otvorite VB6 i kreirajte praznu formu
2. kopirajte kod
3.Treba postaviti
Private Const Naziv_App = "Naziv App"
Private Const Licenca_App = "App_licenca"
Private Const Siguna_Pozicija = "ImeKaoString"( \Access\Security\Trusted Locations\"ImeKaoString")
Private Const Moja_Frontbaza = "MYP.DLL"(Preimenuj te front bazu u NekoIme.dll ili ocx ili bilo koje ime i nastavak)Backend baza mora biti na istoj lokaciji kao i exe
PreuzmiIzvorni kôd (Visual Basic):
  1. Public Enum REG_TOPLEVEL_KEYS
  2.  HKEY_CLASSES_ROOT = &H80000000
  3.  HKEY_CURRENT_CONFIG = &H80000005
  4.  HKEY_CURRENT_USER = &H80000001
  5.  HKEY_DYN_DATA = &H80000006
  6.  HKEY_LOCAL_MACHINE = &H80000002
  7.  HKEY_PERFORMANCE_DATA = &H80000004
  8.  HKEY_USERS = &H80000003
  9. End Enum
  10. Private Const REG_DWORD = 4
  11. Private Const REG_SZ = 1
  12. Private Declare Function RegCreateKey Lib _
  13.    "advapi32.dll" Alias "RegCreateKeyA" _
  14.    (ByVal Hkey As Long, ByVal lpSubKey As _
  15.    String, phkResult As Long) As Long
  16. Private Declare Function RegCloseKey Lib _
  17.    "advapi32.dll" (ByVal Hkey As Long) As Long
  18. Private Declare Function RegSetValueEx Lib _
  19.    "advapi32.dll" Alias "RegSetValueExA" _
  20.    (ByVal Hkey As Long, ByVal _
  21.    lpValueName As String, ByVal _
  22.    Reserved As Long, ByVal dwType _
  23.    As Long, lpData As Any, ByVal _
  24.    cbData As Long) As Long
  25.  
  26. '''''''''''''''''''''
  27. Private Const Naziv_App = "EVD Evidencija rada"
  28. Private Const Licenca_App = "MojProgram_licenca"
  29. Private Const Siguna_Pozicija = "LocationEVD"
  30. Private Const Moja_Frontbaza = "MYP.DLL"
  31. ''''''''''''''''''''''''
  32. Private Function WriteStringToRegistry(Hkey As _
  33.   REG_TOPLEVEL_KEYS, strPath As String, strValue As String, _
  34.   strdata As String, reg As Boolean) As Boolean
  35. Dim bAns As Boolean
  36. On Error GoTo ErrorHandler
  37.    Dim keyhand As Long
  38.    Dim r As Long
  39.    If reg = False Then
  40.    r = RegCreateKey(Hkey, strPath, keyhand)
  41.    If r = 0 Then
  42.         r = RegSetValueEx(keyhand, strValue, 0, _
  43.            REG_SZ, ByVal strdata, Len(strdata))
  44.         r = RegCloseKey(keyhand)
  45.     End If
  46.     Else
  47.    Dim nVal As Long
  48.    nVal = "00000001"
  49.     r = RegCreateKey(Hkey, strPath, keyhand)
  50.    If r = 0 Then
  51.         r = RegSetValueEx(keyhand, strValue, 0, _
  52.            REG_DWORD, nVal, Len(nVal)) '''ByVal strdata, Len(strdata))
  53.        r = RegCloseKey(keyhand)
  54.     End If
  55.     End If
  56.    WriteStringToRegistry = (r = 0)
  57.  
  58. Exit Function
  59.  
  60. ErrorHandler:
  61.     WriteStringToRegistry = False
  62.     Exit Function
  63.    
  64. End Function
  65.  
  66. Private Sub Form_Load()
  67. On Error GoTo Err_Form_Load
  68.  
  69. Dim objShell As Object
  70. Dim objKill As Object
  71. Dim office_path As String, app_path As String, reg_path As String, Description_path As String, AllowSubfolders_path As String
  72. Dim search_mode As Integer, i As Integer, verzija As Integer
  73.  
  74. Set objShell = CreateObject("Wscript.Shell")
  75.  
  76. objShell.run "taskkill.exe /F /IM EXCEL.EXE", 0, True
  77. objShell.run "taskkill.exe /F /IM MSACCESS.EXE", 0, True
  78. For i = 14 To 1 Step -1
  79. If Len(office_path) = 0 Then
  80. verzija = i
  81. office_path = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Office\" & i & ".0\Access\InstallRoot\Path")
  82. reg_path = objShell.RegRead("HKCU\SOFTWARE\Microsoft\Office\" & i & ".0\Access\Security\Trusted Locations\" & Siguna_Pozicija & "\Path")
  83. Description_path = objShell.RegRead("HKCU\SOFTWARE\Microsoft\Office\" & i & ".0\Access\Security\Trusted Locations\" & Siguna_Pozicija & "\Description")
  84. AllowSubfolders_path = objShell.RegRead("HKCU\SOFTWARE\Microsoft\Office\" & i & ".0\Access\Security\Trusted Locations\" & Siguna_Pozicija & "\AllowSubfolders")
  85. End If
  86. Next
  87. If App.Path <> reg_path Then
  88. WriteStringToRegistry HKEY_CURRENT_USER, "Software\Microsoft\Office\" & verzija & ".0\Access\Security\Trusted Locations\" & Siguna_Pozicija, "Path", App.Path, False
  89. WriteStringToRegistry HKEY_CURRENT_USER, "Software\Microsoft\Office\" & verzija & ".0\Access\Security\Trusted Locations\" & Siguna_Pozicija, "Date", Now, False
  90.  
  91. End If
  92. If Description_path <> Licenca_App Then
  93. WriteStringToRegistry HKEY_CURRENT_USER, "Software\Microsoft\Office\" & verzija & ".0\Access\Security\Trusted Locations\" & Siguna_Pozicija, "Description", Licenca_App, False
  94. End If
  95. If AllowSubfolders_path = "" Then
  96. WriteStringToRegistry HKEY_CURRENT_USER, "Software\Microsoft\Office\" & verzija & ".0\Access\Security\Trusted Locations\" & Siguna_Pozicija, "AllowSubfolders", "1", True
  97. End If
  98. If Len(office_path) = 0 Then
  99.     MsgBox "Microsoft(Runtime) Instalacija nije pronaena, Molim vas re-instalirajte Microsoft Office Access (Runtime).", vbCritical, "Program Error!"
  100.     End
  101. End If
  102. app_path = App.Path
  103. objShell.run Chr(34) & office_path & "MSACCESS.EXE" & Chr(34) & " " & Chr(34) & app_path & "\" & Moja_Frontbaza
  104. End
  105. Err_Form_Load:
  106. If Err.Number = -2147024894 Then
  107.     Resume Next
  108. Else
  109.     MsgBox Err.Description
  110. End If
  111. End Sub
preimenujte svoju front mdb u "MYP.DLL" i u isti folder stavite MDB_TO_EXE.exe

Prilozi:
MDB_TO_EXE.rar
Preuzimanja:612
Velicina datoteke:123.36 KB