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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
L

learningvisualc

@learningvisualc
About
Posts
47
Topics
39
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Getting logical drives of all Physical drives
    L learningvisualc

    Hi all, I have 2 hard disk in my system. I want to get Logical drives of both hard drives i.e. Physical drive 1 contains c: and e: partitions and Physical drive 2 contains d: f: and g: partitions. I have used this code to get the hard disk details.... but it is giving wrong result....

    TCHAR szTemp[BUFSIZE];
    szTemp[0] = '\0';

    if (GetLogicalDriveStrings(BUFSIZE-1, szTemp)) 
    {
      TCHAR szName\[MAX\_PATH\];
      TCHAR szDrive\[MAX\_PATH\] = TEXT(" :");
      BOOL bFound = FALSE;
      TCHAR\* p = szTemp;
    
      do 
      {
        // Copy the drive letter to the template string
        \*szDrive = \*p;
    
    
        // Look up each device name
        if (QueryDosDevice(szDrive, szName, BUFSIZE))
        {
    		CString str = szDrive;
    		str = str+szName;
    		//strcat(szDrive , szName);
    		m\_Tree\_Ctrl.InsertItem(str,root,TVI\_LAST);
    		//m\_Tree\_Ctrl.InsertItem("Physical Drive",root,TVI\_LAST);		
        }
    
        // Go to the next NULL character.
        while (\*p++);
      } while (!bFound && \*p); // end of string
    }
    m\_Tree\_Ctrl.Expand(root,TVE\_EXPAND);
    

    It is making a tree like Drives C:\Device\Harddiskvolume1 D:\Device\Harddiskvolume2 E:\Device\Harddiskvolume3 . . . I am not getting what exactly is the problem... Can anybody help me in this... Thanks in advance

    C / C++ / MFC help data-structures

  • Getting ERROR_INSUFFICIENT_BUFFER error in DeviceIoControl Function
    L learningvisualc

    Hi all, I am trying to get Logical drives of a hard disk(\\.\PhysicalDrive0). I have tried using DeviceIoControl function for it but i am getting GetLastError() = 122 i.e. ERROR_INSUFFICIENT_BUFFER error. My code is as follows:-

    HANDLE hDevice;

    hDevice = CreateFile("\\\\.\\PhysicalDrive0"    // drive 
                              0,                    // no access to the drive
                              FILE\_SHARE\_READ |    // share mode
                              FILE\_SHARE\_WRITE, 
                              NULL,              // default security attributes
                              OPEN\_EXISTING,    // disposition
                              0,               // file attributes
                              NULL);          // do not copy file attributes
    
    
    
    PARTITION\_INFORMATION\_EX obj;
    DWORD cb;
    
    
    BOOL iu = DeviceIoControl(hDevice,                             // handle to a partition
    			  IOCTL\_DISK\_GET\_PARTITION\_INFO\_EX,   // dwIoControlCode
    			  NULL,                              // lpInBuffer
    			  0,                                // nInBufferSize
    			  &obj,			           // output buffer
    			  sizeof(obj),                    // size of output buffer
    			  &cb,                           // number of bytes returned
    			  NULL                          // OVERLAPPED structure
    			 );
    if(iu == 0)
    {
    	DWORD err = GetLastError();
    	CString str;
    	str.Format("%d",err);
    	AfxMessageBox(str);
    }
    CloseHandle(hDevice);
    

    I am not getting where exactly is the problem... How can i do this.. Thanks in advance

    C / C++ / MFC help security question

  • Getting LogicalDriveInformation of different hard disks.....
    L learningvisualc

    Hi all, If i have more then one hard disk in my system then how can i get its logical drive information in a format like Hard disk first then C:/,D:/...Then Hard disk2 E:/,F:/... GetLogicalDrive() function retrieves all the Logical drives. How can i do this??? Thanks in advance...

    C / C++ / MFC question

  • Problem in closing the thread
    L learningvisualc

    Hi all, I have made a application in which i have a list control. Suppose that list control has 5 items when i press a button a thread is started using AfxBeginThread. Inside that thread i have made a for loop. That for loop pick up items from list and do some processings say a,b,c. These processing use functions of some other classes to get their result. I have a made a second button, by clicking on that second button i stop my thread using ::TerminateThread(obj,NULL);. My problem is when i click on second button my thread doesn't stop say if it is doing processing b first it will finish doing b then c then it will stop. I tried using ::TerminateThread(obj->m_hThread, NULL); but it also creates problem after some time i.e if i start and stop my processing for 3 times it will not start the process third time. I don't know what to do? Can anybody help me in this? Thanks in advance

    C / C++ / MFC help question

  • disabling alt+space
    L learningvisualc

    Hi all, i want to disable alt + space in my program. How can i do it? Thanks in advance.

    C / C++ / MFC question

  • Second worker thread should start after first has finished it task.
    L learningvisualc

    Hi all, I have two worker thread. one thread is populating the list and second thread is doing operation on that list. my problem is i want that after i have populated the list then only second thread should start. How can i do it? Thanks in advance

    C / C++ / MFC question help

  • Problem in reading a text file
    L learningvisualc

    Hi all, I have made a .txt file in a format that it contains data per line i.e. in the format /*text1*/ /*text2abc*/ And its not defined that how much data it can contain per line. I am reading this file in a per line format basis using this code

    CStdioFile ptr;
    CString str;
    int i = 0;
    ptr.Open(file_name, CFile::ReadWrite, NULL);
    while(ptr.ReadString(str))
    {
    m_List.InsertItem(i,str);
    i++;
    }
    ptr.Close();

    My problem is if a list contains more data(5000 lines or above) its taking a lot of time to read it. I also know that i can read particular number of bytes from buffer but the problem is how can i know that the line has been completely read or not. Can anybody please help me in this? Is there any other way to read thid file. Thanks in advance

    C / C++ / MFC help question

  • How can i use tab inside edit control
    L learningvisualc

    Hi all, I have made a multiline edit control but the problem is when i try to use tab in it the focus shifts to next control. Is there any way to use tab inside edit control. Thanks in advance

    C / C++ / MFC help question

  • edit box taking 1108 lines
    L learningvisualc

    Hi all, I have made a edit control in my application, in that i have selected multiple line option. My problem is if i copy paste some data in that edit control it takes only 1108 lines or approx 28000 characters. Is there any kind of upper limit for edit box. Thanks in advance

    C / C++ / MFC help

  • Either to use thread pooling or some other technique
    L learningvisualc

    Hi all, I am making a sdi application in which i am making various tasks. All tasks are performing a single operation. Now my problem is i want that all the task should start at the same time. One more thing i have to Repetitively perform that operation from my task. Now i am not getting what method to use. Either i should use thread pooling or some other technique.

    C / C++ / MFC help

  • Passing parameter in worker thread
    L learningvisualc

    can you please explain me using a example.

    C / C++ / MFC help tutorial

  • Passing parameter in worker thread
    L learningvisualc

    Hi all, I have made a worker thread. I want to pass a integer as a parameter in my thread. I am not getting how to do it. Can anybody help me this. Thanks in advance

    C / C++ / MFC help tutorial

  • Vertical Scrollbar in list control
    L learningvisualc

    Hi all, I have made a sdi application, in that application i have made a splitter control. On Left and right side of splitter control i have placed a class derived from CFormView. On Left side of Splitter control on form view i have placed a Report style list control. All things are working fine bu my List control is not displaying vertical scrollbar but instead it is displaying a horizontal scrollbar. What can i do? Can anybody help me in this? Thanks in advance

    C / C++ / MFC help question

  • Disabling main application window(Sdi with splitter control)
    L learningvisualc

    Hi all, I have made a sdi application, in that application i have made a splitter control. On Left and right side of splitter control i have placed a class derived from CFormView. I want to disable my window when a particular processing is going on. How can i disable my main application window. Thanks in advance

    C / C++ / MFC question

  • Combining all files in single file
    L learningvisualc

    Hi all, i want to combine all my files into a single file. How can i do it. Thanks in advance

    C / C++ / MFC question

  • error C2872: 'IAccessible' : ambiguous symbol
    L learningvisualc

    Hi all, when i compile my program i get this error

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\oleacc.h(53) : error C2872: 'IAccessible' : ambiguous symbol
    could be 'C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h(1336) : IAccessible'
    or 'e:\Program\debug\mso.tlh(2072) : Office::IAccessible'

    How can i resolve this Thanks in advance

    C / C++ / MFC csharp visual-studio debugging help question

  • Implementing timeout in downloading a webpage
    L learningvisualc

    Hi all, i have written a code to download a webpage using WinInet api's. My code is as follows

    InternetCanonicalizeUrl(site,sCompareURL.GetBufferSetLength(MAX_BUFFER_SIZE),&dwLen,ICU_BROWSER_MODE);
    HINTERNET Ihandle = InternetOpen("Internet Explorer6.0.2900.2180", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);
    HINTERNET hFile = InternetOpenUrl(Ihandle,site,NULL,0,0,0);
    BOOL bRet = InternetReadFile(hFile, szBuffer, MAX_BUFFER_SIZE, &nSize);
    if(!bRet || nSize <= 0)
    break;
    szBuffer[nSize] = '\0';
    m_sHtml += szBuffer;

    This code is working fine, but i want to implement time out in this, i.e i the specified page is not download in specified time then time out shold be displayed. How can i implement this? Thanks in advance

    C / C++ / MFC question json

  • NM_EVENT is not being called
    L learningvisualc

    Hi all, I am working on a sdi application, i have divided my window in two parts using splitter Control. On left side of my window i have used CFormView class. On that dialog i have put a list control. My problem is i have a made a NM_Click event on that list control but when i click on that list that event is not called.... I don't know why this is happening, but can anybody help me in this....

    C / C++ / MFC help

  • CloseHandle() freezes the program...
    L learningvisualc

    Hi all, I have made a application in which i am reading a port using CreateFile() API with FILE_FLAG_OVERLAPPED parameter as NULL. This all processing i have done in worker thread. Everything is working fine but the problem is when i am trying to close the process i am using CloseHandle API and when the control enters in CloseHandle() the program frezees and there is no option of closing it. The code i am using is as below

    void CUse::ThreadStart()
    {
    ThreadHandle = AfxBeginThread(Thread , (LPVOID) this);
    }
    UINT Thread(LPVOID pParam)
    {
    serial_handle = CreateFile(port_arg, GENERIC_READ | GENERIC_WRITE,
    0, NULL, OPEN_EXISTING,NULL,NULL);
    .
    .
    .
    .
    //Code for reading the port

    }
    void CUse::OnCancel()
    {
    ThreadHandle->SuspendThread();
    if(MessageBox("Are you sure to stop the process?","ReadingPort",MB_YESNO)==6)
    {
    ZeroMemory(rxBuffer,128);
    ZeroMemory(rxtemp,256);
    tempid=0;
    CloseHandle(serial_handle);
    CDialog::OnCancel();
    ::TerminateThread(ThreadHandle->m_hThread,0);
    }
    else
    ThreadHandle->ResumeThread();
    }

    How to resolve this problem or any alternate way of doing it... Thanks in advance

    C / C++ / MFC json help tutorial question

  • WriteFile returning zero and GetLastError returning 997(ERROR_IO_PENDING)
    L learningvisualc

    Hi all, I am trying to write to a port using CreateFile() and WriteFile() API's, but my WriteFile() is returning zero and on calling GetLastError() its returning error code 997 ERROR_IO_PENDING. I Know how to read a file when this happens but i am not getting how to write the file. Can anybody help me in doing this... Here is the code

    serial_handle = CreateFile(port_arg, GENERIC_READ | GENERIC_WRITE,
    0, NULL, OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);
    success = WriteFile(serial_handle ,&temp,5,&temp1,&overlappRead);

    I am not getting how to move ahead in this case Thanks in advance

    C / C++ / MFC help json 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