示例#1
0
void
DoMAPISendDocuments(HWND hWnd)
{
  ULONG (FAR PASCAL *lpfnMAPISendDocuments) (ULONG ulUIParam, 
          LPTSTR lpszDelimChar, LPTSTR lpszFullPaths, 
          LPTSTR lpszFileNames, ULONG ulReserved);

#ifdef WIN16		
  (FARPROC&) lpfnMAPISendDocuments = GetProcAddress(m_hInstMapi, "MAPISENDDOCUMENTS"); 
#else
  (FARPROC&) lpfnMAPISendDocuments = GetProcAddress(m_hInstMapi, "MAPISendDocuments"); 
#endif
  
  if (!lpfnMAPISendDocuments)
  {
    ShowMessage(hWnd, "Unable to locate MAPI function.");
    return;
  }

  char  msg[1024];
  char  tempFileName[_MAX_PATH] = "";
  char  lpszFullPaths[(_MAX_PATH + 1) * 4] = "";
  char  lpszFileNames[(_MAX_PATH + 1) * 4] = "";

  // Now get the names of the files to attach...
  GetDlgItemText(hWnd, ID_EDIT_ATTACH1, tempFileName, sizeof(tempFileName));
  TackItOn(lpszFullPaths, lpszFileNames, tempFileName); 

  GetDlgItemText(hWnd, ID_EDIT_ATTACH2, tempFileName, sizeof(tempFileName));
  TackItOn(lpszFullPaths, lpszFileNames, tempFileName); 

  GetDlgItemText(hWnd, ID_EDIT_ATTACH3, tempFileName, sizeof(tempFileName));
  TackItOn(lpszFullPaths, lpszFileNames, tempFileName); 

  GetDlgItemText(hWnd, ID_EDIT_ATTACH4, tempFileName, sizeof(tempFileName));
  TackItOn(lpszFullPaths, lpszFileNames, tempFileName); 

  LONG  rc = (*lpfnMAPISendDocuments)
        ( (ULONG) hWnd,        
          lpszDelimChar, 
          lpszFullPaths, 
          lpszFileNames, 
          0);

  if (rc == SUCCESS_SUCCESS)
  {
    ShowMessage(hWnd, "Success with MAPISendDocuments");
    SetFooter("MAPISendDocuments success");
  }
  else
  {
    wsprintf(msg, "FAILURE: Return code %d from MAPISendDocuments\nError=[%s]", 
                      rc, GetMAPIError(rc));
    ShowMessage(hWnd, msg);
    SetFooter("MAPISendDocuments failed");
  }
}
char * const MemoryManager::CoalesceWithPreviousBlock(char * const ptr)
{
	if (IsPreviousBlockFree(ptr) && IsValidAddress(GetPreviousBlock(ptr)))
	{

		//	Remove previous block from free blocks
		freeBlocks.remove((Node*)GetPreviousBlock(ptr));


		//	Little trick:
		//		Set the pointer to point to the previous free block
		(char*)ptr = GetPreviousBlock(ptr);

		//Update header
		size_t newHeaderData = GetHeader(ptr) + GetHeader(GetNextBlock(ptr));
		SetHeader(ptr, newHeaderData);
		//Update footer
		SetFooter(ptr, newHeaderData);

		return ptr;
	}
	else
	{
		return ptr;
	}
}
示例#3
0
void CSearchPanel::OnSkinChange()
{
	CString strCaption;
	
	LoadString( strCaption, IDS_SEARCH_PANEL_INPUT_CAPTION );
	m_boxSearch.SetCaption( strCaption );
	LoadString( strCaption, IDS_SEARCH_PANEL_RESULTS_CAPTION );
	m_boxResults.SetCaption( strCaption );
	LoadString( strCaption, IDS_SEARCH_PANEL_ADVANCED );
	m_boxAdvanced.SetCaption( strCaption );
	
	SetWatermark( _T("CSearchPanel") );
	SetFooter( _T("CSearchPanel.Footer") );
	
	m_boxSearch.SetWatermark( _T("CSearchInputBox") );
	m_boxSearch.SetCaptionmark( _T("CSearchInputBox.Caption") );
	m_boxSearch.OnSkinChange();

	m_boxAdvanced.SetWatermark( _T("CSearchAdvancedBox") );
	m_boxAdvanced.SetCaptionmark(  _T("CSearchAdvancedBox.Caption") );
	m_boxAdvanced.OnSkinChange();
	
	m_boxSchema.SetWatermark( _T("CSearchSchemaBox") );
	m_boxSchema.SetCaptionmark( _T("CSearchSchemaBox.Caption") );
	
	m_boxResults.SetWatermark( _T("CSearchResultsBox") );
	m_boxResults.SetCaptionmark(  _T("CSearchResultsBox.Caption") );
	
	Invalidate();
}
void MemoryManager::MarkBlockAsAllocated(char * const ptr)
{
	size_t header = (((GetHeader(ptr) ^ (1 << (4 * sizeof(size_t)-1)))));
	SetHeader(ptr, header);

	size_t footer = (((GetFooter(ptr) ^ (1 << (4 * sizeof(size_t)-1)))));
	SetFooter(ptr, footer);
}
示例#5
0
int CInnerPanel::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if ( CTaskPanel::OnCreate( lpCreateStruct ) == -1 )return -1;
	
	SetOwner( GetParent() );
	SetFooter( NULL, TRUE );
	
//	m_wndVideo.Create( this, 140, _T("±¾µØÊÓƵ"), IDI_TASKPANEL );
	AddBox( &wndVideo );
	
	return 0;
}
示例#6
0
int CNetworkPanel::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if ( CTaskPanel::OnCreate( lpCreateStruct ) == -1 )return -1;
	
	SetOwner( GetParent() );
	SetFooter( NULL, TRUE );
	
	m_wndTask.Create( this, 112, _T("²Ù×÷"), IDI_TASKPANEL );
	AddBox( &m_wndTask );
	
	m_wndMonitor.Create( this, 38, _T("¼àÊÓ"), IDI_SEARCH_FOLDER );
	AddBox( &m_wndMonitor );
	
	return 0;
}
示例#7
0
void CHomePanel::OnSkinChange()
{
	SetWatermark( _T("CHomePanel") );
	SetFooter( _T("CHomePanel.Footer") );

	m_boxConnection.OnSkinChange();
	m_boxLibrary.OnSkinChange();
	m_boxDownloads.OnSkinChange();
	m_boxUploads.OnSkinChange();
	Update();
	Invalidate();

	// ToDo: Fix need for duplicate code workaround
	m_boxConnection.OnSkinChange();
	m_boxLibrary.OnSkinChange();
	m_boxDownloads.OnSkinChange();
	m_boxUploads.OnSkinChange();
	Update();
	Invalidate();
}
char * const MemoryManager::CoalesceWithNextBlock(char * const ptr)
{
	if (IsNextBlockFree(ptr) && IsValidAddress(GetNextBlock(ptr)))
	{
		//Remove next block from free blocks
		freeBlocks.remove((Node*)GetNextBlock(ptr));
		
		ForwardIteratationOverFreeBlocks();

		//Update header
		size_t newHeaderData = GetHeader(ptr) + GetHeader(GetNextBlock(ptr));
		SetHeader(ptr, newHeaderData);
		//Update footer
		SetFooter(ptr, newHeaderData);
		return ptr;
	}
	else
	{
		return ptr;
	}
}
///	Main function to allocate memory:
///
char* MemoryManager::Malloc(size_t size)
{
	char * pointerToBlock = NULL;
	size_t sizeOfFreeBlock;
	ForwardIteratationOverFreeBlocks();

	for (Iterator it = freeBlocks.getIterator(); !it.end(); it.moveToNext())
	{
		
		sizeOfFreeBlock = GetHeader(it.getAddressOfFreeBlock());
		//	If the block is large enough
		if (sizeOfFreeBlock >= size)
		{
			pointerToBlock = it.getAddressOfFreeBlock();
			//	Remove the Node  from the block`s payload area so it can be used
			freeBlocks.remove((Node*) pointerToBlock);
			break;
		}
	}

	//	If no free block was found
	if (!pointerToBlock)
	{
		return NULL;
	}

	//	Set header of the block
	SetHeader(pointerToBlock, size);
	
	//	Set footer of the block
	SetFooter(pointerToBlock, size);

	//	Mark the block as allocated (set it`s highest bit)
	MarkBlockAsAllocated(pointerToBlock);

	//	The remaining size of the returned free block
	size_t freeBlockSize = sizeOfFreeBlock - size;

	//	Put new free block at the remaining unused payload area
	//		1.Put header
	//		2.Put its address after the header
	//		3.Put footer
	//		4.Insert free block into free blocks list

	//	1.Put header
	size_t *header = (size_t*)(pointerToBlock + size - sizeof(size_t*));
	*header = freeBlockSize;

	//	2.Put its address after the header
	Node *freeBlock = (Node*)(pointerToBlock + size);
	(char*)freeBlock->addressOfFreeBlock = pointerToBlock + size;
	freeBlock->next = NULL;
	freeBlock->previous = NULL;
	
	//	3.Put footer
	size_t *footer = (size_t*)(freeBlock->addressOfFreeBlock - sizeof(size_t*) + (freeBlockSize - sizeof(size_t*)));
	*footer = freeBlockSize;

	//	4.Insert free block into free blocks list
	freeBlocks.insertAtBeginning(freeBlock);

	return pointerToBlock;
}
示例#10
0
/**
 * @brief oneM2M V1 request
 * @param[in] resourceType : oneM2M resource type value
 * @param[in] operation : operation
 * @param[in] to : target
 * @param[in] ri : request id
 * @param[in] pc : other attributes
 * @return int : result code
 */ 
int tp_oneM2M_V1_Request(int resourceType, int operation, char* to, char* ri, void* pc) {
    int rc = CheckAttributes(resourceType, operation, to, ri, pc);
    if(rc != TP_SDK_SUCCESS) {
        return rc;
    }
    char payload[1024];
    memset(payload, 0, sizeof(payload));
    
    SetHeader(payload, resourceType, operation, to, ri);

    switch(resourceType) {
        case CSEBase:
            {
            oneM2M_CSEBase* CSEBase = (oneM2M_CSEBase *)pc;
            oneM2M_Attribute attr = {ATTR_FR, CSEBase->ni};
            SetElement(payload, &attr, 1);
            }
            break;
        case node:
            {
            oneM2M_node* node = (oneM2M_node *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, node->ni}, {ATTR_NM, node->ni}, {ATTR_DKEY, node->dKey}};
            SetElement(payload, attr, 3);
            if(operation != DELETE) {
                oneM2M_Attribute pc[] = {{ATTR_NI, node->ni}, {ATTR_HCL, node->hcl}, {ATTR_MGA, node->mga}};
                SetPCElement(payload, pc, resourceType, 3);
            }
            }
            break;
        case remoteCSE:
            {
            oneM2M_remoteCSE* remoteCSE = (oneM2M_remoteCSE *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, remoteCSE->ni}, {ATTR_PASSCODE, remoteCSE->passCode}, {ATTR_DKEY, remoteCSE->dKey}, {ATTR_NM, remoteCSE->nm}};
            SetElement(payload, attr, 4);
            if(operation != DELETE) {
                oneM2M_Attribute pc[] = {{ATTR_CST, remoteCSE->cst}, {ATTR_CSI, remoteCSE->ni}, {ATTR_POA, remoteCSE->poa}, {ATTR_RR, remoteCSE->rr},  {ATTR_NL, remoteCSE->nl}};
                SetPCElement(payload, pc, resourceType, 5);
            }
            }
            break;            
        case container:
            {
            oneM2M_container* container = (oneM2M_container *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, container->ni}, {ATTR_NM, container->nm}, {ATTR_DKEY, container->dKey}};
            SetElement(payload, attr, 3);
            if(operation != DELETE) {
                oneM2M_Attribute lbl = {ATTR_LBL, container->lbl};
                SetPCElement(payload, &lbl, resourceType, 1);
            }
            }
            break;
        case mgmtCmd:
            {
            oneM2M_mgmtCmd* mgmtCmd = (oneM2M_mgmtCmd *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, mgmtCmd->ni}, {ATTR_NM, mgmtCmd->nm}, {ATTR_DKEY, mgmtCmd->dKey}, {ATTR_UKEY, mgmtCmd->uKey}};
            SetElement(payload, attr, 4);
            if(operation != DELETE) {
                oneM2M_Attribute pc[] = {{ATTR_CMT, mgmtCmd->cmt}, {ATTR_EXE, mgmtCmd->exe}, {ATTR_EXT, mgmtCmd->ext}, {ATTR_LBL, mgmtCmd->lbl}};
                SetPCElement(payload, pc, resourceType, 4);
            }
            }
            break;
        case contentInstance:
            {
            oneM2M_contentInstance* contentInstance = (oneM2M_contentInstance *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, contentInstance->ni}, {ATTR_DKEY, contentInstance->dKey}};
            SetElement(payload, attr, 2);
            if(operation != DELETE) {
                oneM2M_Attribute pc[] = {{ATTR_CNF, contentInstance->cnf}, {ATTR_CON, contentInstance->con}, {ATTR_LBL, contentInstance->lbl}};
                SetPCElement(payload, pc, resourceType, 3);
            }
            }
            break;
        case locationPolicy:
            {
            oneM2M_locationPolicy* locationPolicy = (oneM2M_locationPolicy *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, locationPolicy->ni}, {ATTR_DKEY, locationPolicy->dKey}, {ATTR_NM, locationPolicy->nm}};
            SetElement(payload, attr, 3);
            if(operation != DELETE) {
                oneM2M_Attribute pc[] = {{ATTR_LOS, locationPolicy->los}, {ATTR_LBL, locationPolicy->ni}};
                SetPCElement(payload, pc, resourceType, 2);
            }
            }
            break;
        case AE:
            {
            oneM2M_AE* AE = (oneM2M_AE *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, AE->ni}, {ATTR_DKEY, AE->dKey}};
            SetElement(payload, attr, 2);
            if(operation != DELETE) {
                oneM2M_Attribute pc[] = {{ATTR_API, AE->api}, {ATTR_APN, AE->apn}};
                SetPCElement(payload, pc, resourceType, 2);
            }
            }
            break;
        case mgmtObj:
            {
            oneM2M_areaNwkInfo* areaNwkInfo = (oneM2M_areaNwkInfo *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, areaNwkInfo->ni}, {ATTR_NM, areaNwkInfo->nm}, {ATTR_DKEY, areaNwkInfo->dKey}};
            SetElement(payload, attr, 3);
            if(operation != DELETE) {
                oneM2M_Attribute pc[] = {{ATTR_MGD, areaNwkInfo->mgd}, {ATTR_ANT, areaNwkInfo->ant}, {ATTR_LDV, areaNwkInfo->ldv}};
                SetPCElement(payload, pc, resourceType, 3);
            }
            }
            break;
        case execInstance:
            {
            oneM2M_mgmtCmdResult* mgmtCmdResult = (oneM2M_mgmtCmdResult *)pc;
            oneM2M_Attribute attr[] = {{ATTR_FR, mgmtCmdResult->ni}, {ATTR_DKEY, mgmtCmdResult->dKey}};
            SetElement(payload, attr, 2);
            oneM2M_Attribute pc[] = {{ATTR_EXR, mgmtCmdResult->exr}, {ATTR_EXS, mgmtCmdResult->exs}};
            SetPCElement(payload, pc, resourceType, 2);
            }
            break;
        default:;
            break;
    }

    SetFooter(payload);
    rc = MQTTPublishMessage(payload);
    return rc;

}
示例#11
0
void          
DoMAPIAddress(HWND hWnd)
{
  ULONG (FAR PASCAL *lpfnMAPIAddress) 
                            (LHANDLE lhSession,
                            ULONG ulUIParam,
                            LPSTR lpszCaption,
                            ULONG nEditFields,
                            LPSTR lpszLabels,
                            ULONG nRecips,
                            lpMapiRecipDesc lpRecips,
                            FLAGS flFlags,
                            ULONG ulReserved,
                            LPULONG lpnNewRecips,
                            lpMapiRecipDesc FAR *lppNewRecips);


#ifdef WIN16		
  (FARPROC&) lpfnMAPIAddress = GetProcAddress(m_hInstMapi, "MAPIADDRESS"); 
#else
  (FARPROC&) lpfnMAPIAddress = GetProcAddress(m_hInstMapi, "MAPIAddress"); 
#endif
  
  if (!lpfnMAPIAddress)
  {
    ShowMessage(hWnd, "Unable to locate MAPI function.");
    return;
  }          

  DWORD   i;
  FLAGS   flFlags = 0;
  DWORD   addrCount = 0;
  char    msg[512];
  char    toAddr[128];
  char    ccAddr[128];
  char    bccAddr[128];

  GetDlgItemText(hWnd, ID_EDIT_TOADDRESS, toAddr, sizeof(toAddr));
  GetDlgItemText(hWnd, ID_EDIT_CCADDRESS, ccAddr, sizeof(ccAddr));
  GetDlgItemText(hWnd, ID_EDIT_BCCADDRESS, bccAddr, sizeof(bccAddr));

  if (toAddr[0]) ++addrCount;
  if (ccAddr[0]) ++addrCount;
  if (bccAddr[0]) ++addrCount;

  lpMapiRecipDesc lpRecips = (lpMapiRecipDesc) malloc((size_t) (sizeof(MapiRecipDesc) * addrCount));
  if (!lpRecips)
  {
    return;
  }

  memset(lpRecips, 0, (size_t) (sizeof(MapiRecipDesc) * addrCount));

  DWORD       rCount = 0;
  if (toAddr[0] != '\0')
  {
    lpRecips[rCount].lpszName = strdup("To Address Name");
    lpRecips[rCount].lpszAddress = strdup(toAddr);
    lpRecips[rCount].ulRecipClass = MAPI_TO;
    rCount++;
  }

  if (ccAddr[0] != '\0')
  {
    lpRecips[rCount].lpszName = strdup("CC Address Name");
    lpRecips[rCount].lpszAddress = strdup(ccAddr);
    lpRecips[rCount].ulRecipClass = MAPI_CC;    
    rCount++;
  }

  if (bccAddr[0] != '\0')
  {
    lpRecips[rCount].lpszName = strdup("BCC Address Name");
    lpRecips[rCount].lpszAddress = strdup(bccAddr);
    lpRecips[rCount].ulRecipClass = MAPI_BCC;
    rCount++;
  }
  
  ULONG             newRecips;
  lpMapiRecipDesc   lpNewRecips;

  // Finally, make the call...
  LONG  rc = (*lpfnMAPIAddress)
                     (mapiSession,
                      0,
                      "MAPI Test Address Picker",
                      0,
                      NULL,
                      rCount,
                      lpRecips,
                      0,
                      0,
                      &newRecips,
                      &lpNewRecips);
  if (rc == SUCCESS_SUCCESS)
  {
    for (i=0; i<newRecips; i++)
    {
      char  tMsg[512];

      wsprintf(tMsg, "User %d\nName=[%s]\nEmail=[%s]\nType=[%d]", 
            i, 
            lpNewRecips[i].lpszName, 
            lpNewRecips[i].lpszAddress, 
            lpNewRecips[i].ulRecipClass);
      ShowMessage(hWnd, tMsg);
    }

    SetFooter("MAPIAddress success");

    DoMAPIFreeBuffer(hWnd, lpNewRecips, TRUE);
  }
  else
  {
    wsprintf(msg, "FAILURE: Return code %d from MAPIAddress\nError=[%s]", 
                      rc, GetMAPIError(rc));
    ShowMessage(hWnd, msg);
    SetFooter("MAPIAddress failed");
  }

  // Now cleanup and move on...
  for (i=0; i<rCount; i++)
  {
    FreeMAPIRecipient(&(lpRecips[i]));
  }
}
示例#12
0
void
DoMAPISaveMail(HWND hWnd)
{
  ULONG (FAR PASCAL *lpfnMAPISaveMail) (LHANDLE lhSession, ULONG ulUIParam, 
                  lpMapiMessage lpMessage, FLAGS flFlags, ULONG ulReserved,
                  LPTSTR lpszMessageID);

#ifdef WIN16		
  (FARPROC&) lpfnMAPISaveMail = GetProcAddress(m_hInstMapi, "MAPISAVEMAIL"); 
#else
  (FARPROC&) lpfnMAPISaveMail = GetProcAddress(m_hInstMapi, "MAPISaveMail"); 
#endif
  
  if (!lpfnMAPISaveMail)
  {
    ShowMessage(hWnd, "Unable to locate MAPI function.");
    return;
  }          

  FLAGS   flFlags = 0;
  char    msg[512];
  char    file1[_MAX_PATH] = "";
  char    file2[_MAX_PATH] = "";
  char    file3[_MAX_PATH] = "";
  char    file4[_MAX_PATH] = "";
  char    toAddr[128];
  char    ccAddr[128];
  char    bccAddr[128];
  char    subject[128];
  char    noteText[4096];
  char    dateReceived[128] = "N/A";
  char    threadID[128] = "N/A";
  char    origName[128] = "N/A";
  char    origAddress[128] = "N/A";

  GetDlgItemText(hWnd, ID_EDIT_TOADDRESS, toAddr, sizeof(toAddr));
  GetDlgItemText(hWnd, ID_EDIT_CCADDRESS, ccAddr, sizeof(ccAddr));
  GetDlgItemText(hWnd, ID_EDIT_BCCADDRESS, bccAddr, sizeof(bccAddr));
  GetDlgItemText(hWnd, ID_EDIT_SUBJECT, subject, sizeof(subject));
  GetDlgItemText(hWnd, ID_EDIT_NOTETEXT, noteText, sizeof(noteText));

  // Build the message to send off...
  lpMapiMessage  msgPtr = (MapiMessage *)malloc(sizeof(MapiMessage));
  if (msgPtr == NULL)
  {
    return;
  }
  
  memset(msgPtr, 0, sizeof(MapiMessage)); 

  //
  // At this point, we need to populate the structure of information
  // we are passing in via the *lppMessage
  //

  // Set all of the general information first!
  msgPtr->lpszSubject = strdup(subject);
  msgPtr->lpszNoteText = strdup(noteText);
  msgPtr->lpszDateReceived = strdup(dateReceived);
  msgPtr->lpszConversationID = strdup(threadID);
  msgPtr->flFlags = flFlags;

  // Now deal with the recipients of this message
  DWORD       realRecips = 0;
  if (toAddr[0] != '\0')    ++realRecips;
  if (ccAddr[0] != '\0')    ++realRecips;
  if (bccAddr[0] != '\0')   ++realRecips;

  msgPtr->lpRecips = (lpMapiRecipDesc) malloc((size_t) (sizeof(MapiRecipDesc) * realRecips));
  if (!msgPtr->lpRecips)
  {
    FreeMAPIMessage(msgPtr);
    return;
  }

  msgPtr->nRecipCount = realRecips;
  memset(msgPtr->lpRecips, 0, (size_t) (sizeof(MapiRecipDesc) * msgPtr->nRecipCount));

  DWORD       rCount = 0;
  if (toAddr[0] != '\0')
  {
    msgPtr->lpRecips[rCount].lpszName = strdup(toAddr);
    msgPtr->lpRecips[rCount].lpszAddress = strdup(toAddr);
    msgPtr->lpRecips[rCount].ulRecipClass = MAPI_TO;
    rCount++;
  }

  if (ccAddr[0] != '\0')
  {
    msgPtr->lpRecips[rCount].lpszName = strdup(ccAddr);
    msgPtr->lpRecips[rCount].lpszAddress = strdup(ccAddr);
    msgPtr->lpRecips[rCount].ulRecipClass = MAPI_CC;    
    rCount++;
  }

  if (bccAddr[0] != '\0')
  {
    msgPtr->lpRecips[rCount].lpszName = strdup(bccAddr);
    msgPtr->lpRecips[rCount].lpszAddress = strdup(bccAddr);
    msgPtr->lpRecips[rCount].ulRecipClass = MAPI_BCC;
    rCount++;
  }

  // Now get the names of the files to attach...
  GetDlgItemText(hWnd, ID_EDIT_ATTACH1, file1, sizeof(file1));
  GetDlgItemText(hWnd, ID_EDIT_ATTACH2, file2, sizeof(file2));
  GetDlgItemText(hWnd, ID_EDIT_ATTACH3, file3, sizeof(file3));
  GetDlgItemText(hWnd, ID_EDIT_ATTACH4, file4, sizeof(file4));

  DWORD       realFiles = 0;
  if (file1[0] != '\0')    ++realFiles;
  if (file2[0] != '\0')    ++realFiles;
  if (file3[0] != '\0')    ++realFiles;
  if (file4[0] != '\0')    ++realFiles;

  // Now deal with the list of attachments! Since the nFileCount should be set
  // correctly, this loop will automagically be correct
  //
  msgPtr->nFileCount = realFiles;
  if (realFiles > 0)
  {
    msgPtr->lpFiles = (lpMapiFileDesc) malloc((size_t) (sizeof(MapiFileDesc) * realFiles));
    if (!msgPtr->lpFiles)
    {
      FreeMAPIMessage(msgPtr);
      return;
    }

    memset(msgPtr->lpFiles, 0, (size_t) (sizeof(MapiFileDesc) * msgPtr->nFileCount));
  }

  rCount = 0;
  if (file1[0] != '\0')
  {
    msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file1);
    msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file1);
    ++rCount;
  }

  if (file2[0] != '\0')
  {
    msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file2);
    msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file2);
    ++rCount;
  }

  if (file3[0] != '\0')
  {
    msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file3);
    msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file3);
    ++rCount;
  }

  if (file4[0] != '\0')
  {
    msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file4);
    msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file4);
    ++rCount;
  }

  // Finally, make the call...
  LONG  rc = (*lpfnMAPISaveMail)
           (mapiSession, 
           (ULONG) hWnd, 
           msgPtr, 
           flFlags, 
           0, NULL);

  if (rc == SUCCESS_SUCCESS)
  {
    ShowMessage(hWnd, "Success with MAPISaveMail");
    SetFooter("MAPISaveMail success");
  }
  else
  {
    wsprintf(msg, "FAILURE: Return code %d from MAPISaveMail\nError=[%s]", 
                      rc, GetMAPIError(rc));
    ShowMessage(hWnd, msg);
    SetFooter("MAPISaveMail failed");
  }

  // Now cleanup and move on...
  FreeMAPIMessage(msgPtr);
}