Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

Dhiraj kumar Saini

@Dhiraj kumar Saini
About
Posts
282
Topics
123
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Following code unable to write/upload file on a HTTP Server
    D Dhiraj kumar Saini

    My following code is unable to upload/write file on the server. Please tell me whats wrong or how can i upload it in a different way on an HTTP Server. I am using MFC.

    INTERNET_BUFFERS BufferIn = {0};
    DWORD dwBytesRead;
    DWORD dwBytesWritten;
    BYTE pBuffer[1024]; // Read from file in 1K chunks
    BOOL bRead, bRet;
    HANDLE hFile;

    HINTERNET hSession = InternetOpen(NULL,
                                      INTERNET\_OPEN\_TYPE\_PRECONFIG,
                                      NULL,
                                      NULL,
                                      0);
    HINTERNET hConnection = InternetConnect(hSession, 
                                            \_T("www.crmpanel.com"),  // Server
                                            INTERNET\_DEFAULT\_HTTP\_PORT,
                                            NULL,     // Username
                                            NULL,     // Password
                                            INTERNET\_SERVICE\_HTTP,
                                            0,        // Synchronous
                                            NULL);    // No Context
    
    
    
    
     BufferIn.dwStructSize = sizeof( INTERNET\_BUFFERS );
    
     HINTERNET hRequest = HttpOpenRequest(hConnection,
    										\_T("PUT"),
    										\_T("cp3/wn\_fupload-oo.php"),
    										NULL,
    										NULL,
    										NULL,
    										0,
    										0);
     if (!hRequest)
     {
       //printf("Failed to open request handle: %lu\\n", GetLastError ());
    	 MessageBox(\_T("Failed to open request handle:"),NULL,MB\_OK);
       return ;
     }
    
    //HttpAddRequestHeaders(hRequest, \_T("Content-Type: multipart/form-data;sid=52501;"), -1, HTTP\_ADDREQ\_FLAG\_ADD);
    
    
    
    
     hFile = CreateFile (\_T("c:\\\\Image1.gif"),
    					GENERIC\_READ,
    					FILE\_SHARE\_READ,
    					NULL,
    					OPEN\_EXISTING,
    					FILE\_ATTRIBUTE\_NORMAL,
    					NULL);
    
     if (hFile == INVALID\_HANDLE\_VALUE)
     {
       //printf("\\nFailed to open local file.");
        MessageBox(\_T("Failed to open local file"),NULL,MB\_OK);
       return ;
     }
    
    
    
     BufferIn.dwBufferTotal = GetFileSize(hFile, NULL);
     MessageBox(\_T("File size is"),NULL,MB\_OK);
     //printf ("File size is %d\\n");//, BufferIn.dwBufferTotal );
    
    // CString h = \_T("Content-Type: multipart/form-data");
    
    //CString s = \_T("filename=Iamge1.xml&filetype=gif&filesize=70204&sid=52501&csesid=111");
    
    //BOOL bo = HttpSendRequest(hRequest,(LPCTSTR)&h, h.GetLength(),(LPVOID)&s ,s.GetLength());
    
    C / C++ / MFC c++ php com sysadmin xml

  • how to find if the file is transferred [modified]
    D Dhiraj kumar Saini

    Hello , I am sending a gif file to the HTTP Server. Is there any way to find that the file is transfered successfully. If yes how?

    INTERNET_BUFFERS BufferIn = {0};
    DWORD dwBytesRead;
    DWORD dwBytesWritten;
    BYTE pBuffer[1024]; // Read from file in 1K chunks
    BOOL bRead, bRet;
    HANDLE hFile;

    HINTERNET hSession = InternetOpen(NULL,
                                      INTERNET\_OPEN\_TYPE\_PRECONFIG,
                                      NULL,
                                      NULL,
                                      0);
    HINTERNET hConnection = InternetConnect(hSession, 
                                            \_T("www.crmpanel.com"),  // Server
                                            INTERNET\_DEFAULT\_HTTP\_PORT,
                                            NULL,     // Username
                                            NULL,     // Password
                                            INTERNET\_SERVICE\_HTTP,
                                            0,        // Synchronous
                                            NULL);    // No Context
    
    
    
    
     BufferIn.dwStructSize = sizeof( INTERNET\_BUFFERS );
    
     HINTERNET hRequest = HttpOpenRequest(hConnection,
    										\_T("PUT"),
    										\_T("/temp"),
    										NULL,
    										NULL,
    										NULL,
    										0,
    										0);
     if (!hRequest)
     {
       //printf("Failed to open request handle: %lu\\n", GetLastError ());
    	 MessageBox(\_T("Failed to open request handle:"),NULL,MB\_OK);
       return ;
     }
    
    
    
     hFile = CreateFile (\_T("c:\\\\Image1.gif"),
    					GENERIC\_READ,
    					FILE\_SHARE\_READ,
    					NULL,
    					OPEN\_EXISTING,
    					FILE\_ATTRIBUTE\_NORMAL,
    					NULL);
    
     if (hFile == INVALID\_HANDLE\_VALUE)
     {
      	    MessageBox(\_T("Failed to open local file"),NULL,MB\_OK);
       return ;
     }
    
    
    
     BufferIn.dwBufferTotal = GetFileSize(hFile, NULL);
     MessageBox(\_T("File size is"),NULL,MB\_OK);
    
     if(!HttpSendRequestEx(hRequest, &BufferIn, NULL, HSR\_INITIATE, 0))
     {
    	 MessageBox(\_T("Error on HttpSendRequestEx"),NULL,MB\_OK);
    			       return ;
     }
    
    
     DWORD sum = 0;
     do
     {
       if  (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
           &dwBytesRead, NULL)))
       {
    	 MessageBox(\_T("ReadFile failed on buffer"),NULL,MB\_OK);
                 break;
       }
       if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
           &dwBytesWritten)))
       {
    	 MessageBox(\_T
    
    C / C++ / MFC com sysadmin help tutorial question

  • File Transfer using HTTP Connection.
    D Dhiraj kumar Saini

    The problem I am facing is that after I am capturing the desktop and saving it in a gif file I need to send this file to a HTTP server for uploading and also i need some additional parameters along with the file. How to achieve this. If possible please help me. Thanks In Advance.

    C / C++ / MFC c++ sysadmin help

  • File Transfer using HTTP Connection.
    D Dhiraj kumar Saini

    yes u are correct. Sorry I wont post it again as i was unaware of down voting by admin. Anyways Thanks.

    C / C++ / MFC c++ sysadmin help

  • File Transfer using HTTP Connection.
    D Dhiraj kumar Saini

    Hi, I am working on an MFC application where I am capturing acreen saving it in a gif file and need to transfer to the server using HTTP . Please help me with some code. Thanks In Advance Dhiraj

    C / C++ / MFC c++ sysadmin help

  • Screen Capturing in JPG format and not Bitmap
    D Dhiraj kumar Saini

    I am able to save it in JPG format but the size of the file is somewhere around 150KB. Is there any way I can Optimize the size to somewhere below 100KB as it needs to be sent to the server for real time monitoring. Thanks In Advance

    C / C++ / MFC graphics sysadmin

  • Screen Capturing in JPG format and not Bitmap
    D Dhiraj kumar Saini

    Thanks its working!

    C / C++ / MFC graphics sysadmin

  • Screen Capturing in JPG format and not Bitmap
    D Dhiraj kumar Saini

    Thanks Its Working :)

    C / C++ / MFC graphics sysadmin

  • Screen Capturing in JPG format and not Bitmap
    D Dhiraj kumar Saini

    If you can provide some code or example as to how ro convert it would of great help.

    C / C++ / MFC graphics sysadmin

  • Screen Capturing in JPG format and not Bitmap
    D Dhiraj kumar Saini

    I want to make a screen capturing application which captures and stores in JPG or GIF format and not in Bitmap format. I have examples from codeproject but all of them are using Bitmap b'coz of which when i save themin a bitmap file for sending to the server the file size if too much. Thanks & Regards. Dhiraj Kumar Saini

    C / C++ / MFC graphics sysadmin

  • Save CBitmap to File
    D Dhiraj kumar Saini

    Thanx its working.

    C / C++ / MFC help tutorial

  • Save CBitmap to File
    D Dhiraj kumar Saini

    Ya sure.

    void CCaptureDesktopDlg::OnBnClickedButton1()
    {
    // TODO: Add your control notification handler code here

    CString sFName;
    CDC ScreenDC;
    ScreenDC.Attach(::GetDC(NULL));

    CBitmap Capture;
    CSize Dimensions(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
    Capture.CreateCompatibleBitmap(&ScreenDC, Dimensions.cx, Dimensions.cy);

    CDC MemDC;
    MemDC.CreateCompatibleDC(&ScreenDC);

    CBitmap *OldBitmap = MemDC.SelectObject(&Capture);

    MemDC.BitBlt(0, 0, Dimensions.cx, Dimensions.cy, &ScreenDC, 0, 0, SRCCOPY);

    //added on 28Nov08

    CFileDialog fd( FALSE, // true for open, false for save

    _T("BMP"), // default extention

    NULL, // initial filename in box);

    OFN_HIDEREADONLY & // flags for detailed behaviour

    OFN_OVERWRITEPROMPT,

    NULL, // file-filter pairs

    NULL); // pointer to parent window

    fd.m_ofn.lpstrTitle = _T("Enter file name...");

    fd.m_ofn.lpstrInitialDir = NULL;

    fd.m_ofn.lpstrFilter = _T("BMP files (*.bmp)\000*.BMP\000");

    if(fd.DoModal() == IDOK)

    sFName = fd.GetPathName();

    else

    return;

    HANDLE hDib = DDBToDIB( Capture, BI_RGB, NULL );

    BOOL b = WriteDIB( sFName.GetBuffer(sFName.GetLength()) , hDib);

    if(!b)

    {

    CString sMess = _T("Unable to write to file: \n");

    sMess += sFName;

    AfxMessageBox(sMess);

    }

    MemDC.SelectObject(Capture);

    Capture.Detach(); // make sure bitmap not deleted with CBitmap object

    //----------------

    MemDC.SelectObject(OldBitmap);
    MemDC.DeleteDC();

    ::ReleaseDC(NULL, ScreenDC.Detach());

    }
    BOOL CCaptureDesktopDlg::WriteDIB( LPTSTR szFile, HANDLE hDIB)

    {

    BITMAPFILEHEADER hdr;

    LPBITMAPINFOHEADER lpbi;

    if (!hDIB)

    return FALSE;

    CFile file;

    if( !file.Open( szFile, CFile::modeWrite|CFile::modeCreate) )

    return FALSE;

    lpbi = (LPBITMAPINFOHEADER)hDIB;

    /* int nColors = 1 << lpbi->biBitCount;

    */

    int nColors = 1 << lpbi->biBitCount;

    if (nColors > 256)

    nColors = 0;

    // Fill in the fields of the file header

    hdr.bfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"

    hdr.bfSize = GlobalSize (hDIB) + sizeof( hdr );

    hdr.bfReserved1 = 0;

    hdr.bfReserved2 = 0;

    //// hdr.bfOffBits = (DWORD) (sizeof( hdr ) + lpbi->biSize +

    //// nColors * sizeof(RGBQUAD))

    C / C++ / MFC help tutorial

  • Save CBitmap to File
    D Dhiraj kumar Saini

    Its giving assertion related to size.

    C / C++ / MFC help tutorial

  • Save CBitmap to File
    D Dhiraj kumar Saini

    I have a CBitmap object and want to save it as a file . Please help me how to achieve it. Thanks & regards. Dhiraj

    C / C++ / MFC help tutorial

  • i want make an mfc applicatio for screen capturing
    D Dhiraj kumar Saini

    Hello, I want to make a very small application capable of screen capturing. Plaese help me with some example. Thanks & Regards. Dhiraj

    C / C++ / MFC c++ help tutorial

  • Internet Connection Problem
    D Dhiraj kumar Saini

    Hello, My application is an mfc application which is connected to server throughtout. Now if the internet connection failure is there then then i display a meesgebox that please check your internet connection. And the applications keeps on requesting from the server. How ever if the internet connection does not get better early the the appplicaton keep on requesting from thes server i.e. it gets busy in itself as the messagebox next gets fired after 213 calls. How should i manage it so that it does get busy itself and the user does not have to forcefuuly end it. Thanks In Advance. Dhiraj

    C / C++ / MFC c++ sysadmin help

  • Multiple language display problem in CRichEditCtrl
    D Dhiraj kumar Saini

    Actually I am copying urdu bengali and tamil text from google and pasting it in Edit control till here it is fine but it is not getting displayed in the CRichEditCtrl. Thanks Dhiraj

    C / C++ / MFC c++ help lounge

  • Multiple language display problem in CRichEditCtrl
    D Dhiraj kumar Saini

    Hi, I am working on an mfc application in which there is a chat module. My CRichEditCtrl is able to display chinese, arabic, hindi and several other languages. But it is not possible to display languages such as Urdu, Bengali, Gujrati Tamil etc. What can be the possible reason. Thanks In Advance Dhiraj

    C / C++ / MFC c++ help lounge

  • how to disable double click event on a button.
    D Dhiraj kumar Saini

    actually what i want is that the user can only fire single click event and not double click. That is my meaning of disabling actually the button is not disabled but double click should not do any thing. It should not change its state.

    C / C++ / MFC tutorial

  • how to disable double click event on a button.
    D Dhiraj kumar Saini

    Hello, I want my button to be clicked only once and not twice. What to do. Thanks In Advance. Dhiraj

    C / C++ / MFC tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups