Ejemplo n.º 1
0
void CMailMsg::AddAttachment(WTL::CString sAttachment, WTL::CString sTitle)
{
    strconv_t strconv;
    LPCSTR lpszAttachment = strconv.t2a(sAttachment.GetBuffer(0));
    LPCSTR lpszTitle = strconv.t2a(sTitle.GetBuffer(0));
    m_attachments[lpszAttachment] = lpszTitle;  
}
Ejemplo n.º 2
0
BOOL CMainDlg::RawPrint(LPTSTR fileName)
{
    HANDLE p, f;
    p = f = INVALID_HANDLE_VALUE;
    LPBYTE buffer = NULL;
    DWORD err = ERROR_SUCCESS, w, size, r;
    WTL::CString ballon, message;
    CRPTray rwtray;

    WTL::CString printer = CMainDlg::GetRawPrinter();
    if (!printer.GetLength())
    {
        ::MessageBox(NULL, _(IDS_NOPRINTER), _T("RawPrinter"), MB_OK | MB_ICONERROR);
        return FALSE;
    }

    PRINTER_DEFAULTS defaults = { _T("RAW"), 0, PRINTER_ACCESS_USE };
    DOC_INFO_1 doc = { fileName, NULL, _T("RAW") };

    if ((f = ::CreateFile(fileName,
        GENERIC_READ, FILE_SHARE_READ,
        NULL, OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
    {
        message.Format(_(IDS_ERROR_CREATEFILE), fileName, AtlGetErrorDescription(::GetLastError()));
        ::MessageBox(NULL, message, _T("RawPrinter"), MB_OK | MB_ICONERROR);
            goto end;
    }

    size = ::GetFileSize(f, NULL);
    buffer = (LPBYTE) new BYTE[size];
    ::ReadFile(f, buffer, size, &r, NULL);
    ::CloseHandle(f);

    LPTSTR fn = _tcsrchr(fileName, _T('\\'));
    ballon.Format(_(IDS_PRINTING), fn ? fn + 1: fileName, printer);
    rwtray.Ballon(ballon, 3000);

    CALL(::OpenPrinter(printer.GetBuffer(0), &p, &defaults), OpenPrinter);
    CALL(::StartDocPrinter(p, 1, (LPBYTE) &doc), StartDocPrinter);
    CALL(::StartPagePrinter(p), StartPagePrinter);
    CALL(::WritePrinter(p, buffer, size, &w), WritePrinter);
    CALL(::EndPagePrinter(p), EndPagePrinter);
    CALL(::EndDocPrinter(p), EndDocPrinter);

end:
    if (buffer) delete buffer;
    ClosePrinter(p);
    return TRUE;
}
Ejemplo n.º 3
0
void CMailMsg::SetMessage(WTL::CString sMessage) 
{
    strconv_t strconv;
    LPCSTR lpszMessage = strconv.t2a(sMessage.GetBuffer(0));
    m_sMessage = lpszMessage;
};
Ejemplo n.º 4
0
void CMailMsg::SetSubject(WTL::CString sSubject)
{
    strconv_t strconv;
    LPCSTR lpszSubject = strconv.t2a(sSubject.GetBuffer(0));
    m_sSubject = lpszSubject;
}
Ejemplo n.º 5
0
void CMailMsg::AddRecipient(WTL::CString sAddress)
{
    strconv_t strconv;
    LPCSTR lpszAddress = strconv.t2a(sAddress.GetBuffer(0));
  m_to.push_back(lpszAddress);
}
Ejemplo n.º 6
0
void CMailMsg::SetFrom(WTL::CString sAddress)
{  
    strconv_t strconv;
    LPCSTR lpszAddress = strconv.t2a(sAddress.GetBuffer(0));
    m_from = lpszAddress;
}
Ejemplo n.º 7
0
DWORD WINAPI CMainDlg::DetectVersion(LPVOID lpParameter)
{
    CMainDlg *pThis = static_cast<CMainDlg *> (lpParameter);
    WTL::CString result;
    const wchar_t *p_versionstr;
    const wchar_t *p_versiondat;
    const wchar_t *p_term;
    DWORD res;
    int pos;

    pThis->m_edit.AppendText(L"Detecting scan executable\r\n");

    pThis->m_process = new Process(L"scan.exe /?");
    res = pThis->m_process->Exec(result);
    delete pThis->m_process;
    pThis->m_process = NULL;

    if (res) return -1;

    pos = result.Find(L"Scan engine v");

    if (pos == -1) /* V2 */
    {
        p_versionstr = L"McAfee VirusScan Command Line for Win32 Version: ";
        p_versiondat = L"Dat set version: ";
        p_term = L"\r";
        pThis->m_process = new Process(L"scan.exe /version");
        res = pThis->m_process->Exec(result);
        delete pThis->m_process;
        pThis->m_process = NULL;
        if (res) return -1;
        pos = result.Find(p_versionstr);
        if (pos == -1)
        {
            pThis->m_edit.AppendText(L"Unknown Version\r\n");
            return -1;
        }
        pThis->m_toolversion = 2;
    }
    else /* V1 */
    {
        p_versionstr = L"Scan engine v";
        p_versiondat = L"Virus data file v";
        p_term = L" ";
        pThis->m_toolversion = 1;
    }

    pos += wcslen(p_versionstr);
    WTL::CString verstr = result.Mid(pos);
    pos = verstr.Find(p_term);
    pThis->m_version = verstr.Left(pos);

    pos = result.Find(p_versiondat);
    if (pos == -1)
    {
        pThis->m_edit.AppendText(L"Cannot parse dat version\r\n");
        return -1;
    }

    pos += wcslen(p_versiondat);
    result = result.Mid(pos);
    pThis->m_datversion = _wtoi(result.GetBuffer(0));

    WTL::CString message;
    message.Format(L"Tool version %s - Dat Version %d\r\n", pThis->m_version,  pThis->m_datversion);
    pThis->m_edit.AppendText(message); 

    return 0;
}