There is a volume in my hard drive that currently does not has any drive letter. I need to assign a drive letter to this volume. Please suggest me some way to do so.
If a volume has any drive letter already then I can change it's drive letter by getting it's GUID and assign any other drive letter easily. But if the volume does not has any drive letter then how can I get its GUID to assign a drive letter.
If there is any other way to do this please suggest me.
I think you should get familiar with AfxBeginThread([^])
And its usage, surely u will understand how to do that by understanding about AfxBeginThread.
well here is a code. Make the myMainLooFunc with the specified function signature and static(To know why, check the msdn for more help).
static UINT myMainLoopFunc(LPVOID kodata)
pass the class instance to thread proc as argument and call function from there
e *pE = ... //assign running instance of e. assign this pointer if from inside the class e.
//Thread proc definition
UINT fnThreadProc(LPVOID lpParam)
E *pE = (*pE)lpParam;
pE->myMainLoopFunc(); //call any public function in class e.
But I have faced some problems.
My e class Objects just get a HWND object in their contructor argument
and draw something on it, in myMainLoopFunc() method How ever the code runs with no error But nothing drwan in the window.
But without threading it works perfectly.
Do you have any idea what's the problem.
I've got the following problem with CreateBitmapIndirect(). I've got bitmap data - width, height, bits-per-pixel and array of bits. I'm trying to create HBITMAP by calling CreateBitmapIndirect, but when it's created the biBits of the BITMAP object is NULL. Here is the cpde"
int size = 0, width = 0, height = 0, planes = 0, bpp = 0, r = 0, g = 0, b = 0;
unsigned char* pBits = NULL;
hr = pIShellBmp->GetData( &width, &height, &planes, &bpp, &data ); //my interface which returns serialized bitmap
hr = pIShellBmp->GetColors( &r, &g, &b );
if( SUCCEEDED(hr) )
CComSafeArray<BYTE> bits( data.parray );
pBits = new unsigned char[ bits.GetCount() ]; // this is array of bits in bitmap - it's content of other BITMAP::biBits which I store in IShellBmp interface in COM server (local service)for( int i = 0; i < bits.GetCount(); ++i )
pBits[i] = bits.GetAt( i );
bmp.bmType = 0;
bmp.bmBitsPixel = bpp;
bmp.bmHeight = height;
bmp.bmPlanes = planes;
bmp.bmWidth = width;
bmp.bmWidthBytes = width * bpp / 8 + (width * bpp / 8)%2;
bmp.bmBits = pBits;
HBITMAP hBitmap = CreateBitmapIndirect( &bmp ); // THIS IS OK - bitmap created
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
bmi.bmiHeader.biBitCount = bpp;
bmi.bmiHeader.biClrImportant = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biHeight = height;
bmi.bmiHeader.biPlanes = planes;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biWidth = width;
if( hBitmap == NULL )
DWORD err = GetLastError();
hr = E_FAIL;
DWORD err = SetDIBits( CreateCompatibleDC(NULL), hBitmap, 0, bmp.bmHeight, pBits, &bmi, DIB_RGB_COLORS ); // This line returns 0 - ???
err = GetLastError(); // error code is 0GetObject( hBitmap, sizeof(BITMAP), &bmp ); // bmp.bibits contains NULL - why??
WriteBMPFile( hBitmap, _T("c:\\received.bmp"), CreateCompatibleDC( NULL ) );
For some reasons the lines in bold fail and there is no error code. Can you please help me - where I'm wrong?
Should you be setting bmi.bmiHeader.biSizeImage before calling SetDIBits? I only say this because I found the following I'd used which uses GetDIBits to calculate it's value:
// Calculate the biSizeImage parameter using GetDIBits or manually if this failsint ScanLines = GetDIBits(hMemDC,hBmp,0,B1Win.ylen,NULL,lpbmInfo,DIB_RGB_COLORS);
if(lpbmInfo->bmiHeader.biSizeImage == 0)
lpbmInfo->bmiHeader.biSizeImage = ((((lpbmInfo->bmiHeader.biWidth * lpbmInfo->bmiHeader.biBitCount) + 31) & ~31) >> 3) * lpbmInfo->bmiHeader.biHeight;
// Copy bits from RGB888 to 24 bit DIB and inverting bitmap
ScanLines = (int)(InControl.VideoRoi.ylen); // SetDIBits inverts if height is -ve// biHeight originally set -ve here
ScanLines = SetDIBits(hMemDC,hBmp,0,ScanLines,BDBoard.pcnvBuffer,lpbmInfo,DIB_RGB_COLORS);