Create document version for document already checked-out

Is there a function to create a new version of a document on check-in?

Parents Reply
  • Hmm.  I could be wrong as I'm not a world class programmer, but I'm not sure you understand what LPTSTR is.  Take a look at this page: 

    If I understand the code snippet that you posted, you allocate a pointer to a memory location that is typed to TCHAR. Then you zero out that memory location, which is I believe to be just one TCHAR wide.  Later, in your call to aaApi_DocumentCheckInActionDlg2(), you pass 2000 as the size of the buffer for the return of a comment.  Why? The ProjectWise API function doesn't allocate memory with that value, it is your way of telling the function how big the buffer is that you are pointing to.

    The "correct" way, or at least the "best practice" way, would be to pass the size of your buffer, strcom, the same/similar way that you pass the size to "ZeroMemory()", i.e. the sizeof(strcom) function, which I believe would return zero or perhaps one, since it is a pointer, not an array of TCHAR.

    Take a look at this page: 

    If this is "working", i.e., not crashing, I suspect that it is by chance, but I could be wrong.

    Also, the prototype for aaApi_DocumentCheckInActionDlg2() looks like this:

    pComment is of type LPWSTR, not LPTSTR.  I think these are the same when using UNICODE, but since you are using UNICODE, why not be explicit about it?

    Here's a code snippet that is from an old program I did years ago where I'm allocating memory for a "string" and passing a pointer to that memory location for the function aaApi_GetLastLoginInfo() which is similar to the way aaApi_DocumentCheckInActionDlg2() is expecting a pointer to a buffer for a "string".  Here's the prototype for aaApi_GetLastLoginInfo():

    and a snippet showing how I allocated memory for the strings, and how I pass this onto the function:

    	WCHAR	szDSName[128];			// datasource name
    	WCHAR	szUserName[63];			// user who is logging in
    	WCHAR	szPassWord[128];		// user's password
    	// initalize the WCHAR types
    	wmemset(szDSName,   '\0', sizeof(szDSName)  / sizeof(WCHAR));
    	wmemset(szUserName, '\0', sizeof(szUserName)/ sizeof(WCHAR));
    	wmemset(szPassWord, '\0', sizeof(szPassWord)/sizeof(WCHAR));
    	// get the previous login info if any from the local pw registry
    	hPwReg = aaApi_GetLocalRegistry();
    	bRetCode = aaApi_GetLastLoginInfo
    		hPwReg,								// i  ProjectWise registry handle   
    		szDSName,							// io Datasource name               
    		sizeof(szDSName)/sizeof(WCHAR),		// i  Length of lptstrDataBase      
    		szUserName,							// o  User name                     
    		sizeof(szUserName)/sizeof(WCHAR),	// i  Length of lptstrUser          
    		NULL,								// o  Schema path                   
    		0									// i  Length of lptstrSchema        

    You might want to run your existing code with various sets of data, i.e. large comment strings, and see if it behaves as you expect.  And if not, try modifying to code to look a bit more like my sample snippet and see if that approach works for you.

    Any "world class programmers", or at least those who better understand the workings of "string" in C++ code, who can comment or advise on what I am suggesting?