Create Documents using SDK

Hi guys,

I want to, whenever a user click in a option created in PW and select a File from a FileDialog, this file should be created in PW. The first step of it (Create menu option and FileDialog) was acomplished succesfully. Now, i'm having problems to create the selected file as a document in PW. I tried what is described in this link http://communities.bentley.com/products/projectwise/projectwise_programming/f/342995/t/56503.aspx, but with no success. Could someone help me? Here is the code that i'm trying to create the document in PW (It's in C++ using MFC):

LONG docID = lpDocItem->lDocumentId;
LONG projectID = lpDocItem->lProjectId;

LONG *lngDocID;
*lngDocID = 0;

LONG lngAppID = aaApi_GetFExtensionApplication(L"pdf");
LONG lngWorkSpaceID = aaApi_GetWorkspaceProfileId(projectID, 0);

LPWSTR strWorkingDir = L" ";
BOOL status = aaApi_CreateDocument(lngDocID, projectID, 0, AADMS_FTYPE_UNKNOWN ,
AADMS_ITYPE, lngAppID, 1, lngWorkSpaceID, FileDlg.GetPathName(),
FileDlg.GetFileName(), FileDlg.GetFileName(), NULL, NULL,
false, AADMSDOCCREF_DEFAULT, strWorkingDir,
512, 0);