trouble with aaApi_Login(), and how do I find the correct DLL for declaring a function?

I'm learning how to use the ProjectWise API through VBA, and I'm trying to build a basic Hello World program.  So far, I have:

Public Declare Function aaApi_Initialize Lib "DMSCLI.dll" (ByVal ulModule As Long) As Long
Public Declare Function aaApi_GetCurrentUserId Lib "DMSCLI.dll" () As Long
Public Declare Function aaApi_Login Lib "DMSCLI.dll" (ByVal lDsType As Long, lpctstrDSource As String, ByVal lpctstrUser As String, ByVal lpctstrPassword As String, ByVal lpctstrSchema As String) As Boolean

Sub LogIn()

Dim result1 As Boolean
Dim result2 As Boolean
Dim result3 As Long


'Initialize the API
result1 = aaApi_Initialize(AAMODULE_ALL)
'Login to PW using single sign-on
result2 = aaApi_Login(AAAPIDB_UNKNOWN, "XYZABC.my.site.com:PWOPPID_ABC", vbNullString, vbNullString, vbNullString)
'Get ID for current user
result3 = aaApi_GetCurrentUserId()

End Sub

The aaApi_Login() call is returning false, and I don't know why. I want to use aaApi_GetLastErrorID() to inspect the problem, but I don't know which DLL to use for declaring it.

Short of running a dumpbin on every DLL in the ProjectWise\Bin folder and searching through each dump, is there an easier way to find out which DLL should be used to declare a given function? Is this information available somewhere in the SDK that I've overlooked?

  • Unknown said:

    1. Why would it be "faster" to interact with PW through a wrapper DLL rather then directly using the PW dlls?

    For your first question:

    1. A wrapper DLL could expose a simple interface.  e.g. PWCheckoutDoc("pwname://...").  If you were required to write, migrate, and verify all the necessary ProjectWise functions, types, and parameter calls across the different runtime boundaries (ensuring no memoryallocated by different runtimes occurs) the underlying native C/C++ code in your wrapper does not need to be exposed to the target language (e.g. VBA or .NET).
    2. Making calls across different runtime API boundaries incurs computational and resource overhead.  The fewer times this needs to occur the faster the application will be.
    3. The target API; VBA for this example; though simpler to program in can hide real (logic or explicit) errors in your code making it more difficult to find and debug hidden problem. See my prior suggestions on VBA options to run with for development vs. production below. Microsoft VBA is an interpreted language that certainly has its own overhead to add vs. calling native code functions in a native code application.  Any mission critical sub-second timing related processes will need the additional control that Native code and/or Assembly language can deliver.

    Unknown said:

    2. Custom Module Manager is as far as I see only installed with the SDK. How do you then get your program running at a non-SDK PC?

    For your second question:

    Please see the attached .pdf I have created on this topic.  Simply in your development environment export out the appropriate bitness ProjectWise custom module entries and deploy to your client registries along with your custom module in the ProjectWise bin directory.

     



  • Hi Bob

    Thank you for your very elaborate answers.

    I do however need to get a full understanding of the implications of your statements on VBA usage.

    Let me give an example

    From a VBA application I want to make a list of documents stored in my PW. Should I:

    1. Make one C++-function in a wrapper DLL taking care of everything including login.
    2. Make more C++-function in a wrapper DLL each taking care of the major steps in the process: Login, Setting up document list (filter, sort), Getting the data, Logout.

    And a side question: Is Visual Studio 2010 Express suitable as IDE? If not what is the minimum Visual Studio edition required.

     

     

    Joshua

    I apologize for hijacking your thread.

     

    Thomas 

  • By the way, you don't need Custom Modules if you are creating a stand alone application. Custom modules are for DLLs that are invoked from ProjectWise as it starts and usually contain menu items to dispay in ProjectWise.  You can make a stand alone app in C++ and then see what make sense to put into a C++ COM dll and what makes sense to put into a .NET program.  A standalone application samlple can be found at C:\Program Files (x86)\bentley\ProjectWise\SDK\samples\vaultlist if you have the SDK installed.

         Most likely you will have Login, Logout, and most of your aaApi_function calls wrapped in the same DLL as they have data that they need to share.  Login creates an HDSOURCE that is needed by Logout is an example.