How does one decompile and recompile a database application?

后端 未结 7 1948
逝去的感伤
逝去的感伤 2020-11-21 22:34

I have an Access database application and I would like to know the proper way of decompiling and recompiling it.

7条回答
  •  礼貌的吻别
    2020-11-21 22:41

    I wrote a VBS script to automate the process of decompiling. It's silly that Microsoft hasn't integrated this into Access, considering it is a necessity when developing VBA-heavy applications.

    The script locates MSACCESS.exe and runs Access with the decompile flag on a database located in the parent directory of the script, whose name is given in the code.

    Option Explicit
    Dim MSAccPath
    Dim RegKey
    Dim WSHShell
    Dim currentDirectory
    
    ' Get MSACCESS.exe directory
    RegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\" _
        & "CurrentVersion\App Paths\MSACCESS.EXE\Path"
    Set WSHShell = WScript.CreateObject("WScript.Shell")
    
    ' Get parent directory
    MSAccPath = WSHShell.RegRead(RegKey)
    currentDirectory = WSHShell.CurrentDirectory
    
    ' Decompile
    WSHShell.Run Chr(34) & MSAccPath & "MSACCESS.EXE" & Chr(34) & " " & Chr(34) & currentDirectory & "\..\testdb.accdb" & Chr(34) & " /decompile"
    
    ' Clear shell var
    Set WSHShell = Nothing
    

    Simply paste this text into a document with a .vbs extension and double-click it to run. Access will launch, decompile the compiled P-code ("packed" code), and automatically recompile the VBA source back into P-code.

提交回复
热议问题