|
Can someone explain why I get a Datatype Misalignment error message when I use the ::GetDiskFreeSpaceEx function? I am getting the correct data returned but when I try to save any of the values to a variable I get this error. I've tried delcaring the variable as ULONGLONG or __ui64, but nothing works.
What datatype should the variable be? and should I save the LowPart or QuadPart? I wont ever see more than 2GB of memory space. Does anyone have an example for eMbedded VC++?
Paul Jahans
|
|
|
|
|
Hi, did a quick check on my system and it works fine. Since you didn't post any code, I have no idea why you got a datatype misalignment.
TCHAR buff[200];
ULARGE_INTEGER lFreeCaller, lTotBytes , lTotFreeBytes ;
::GetDiskFreeSpaceEx (NULL, &lFreeCaller, &lTotBytes, &lTotFreeBytes);
swprintf(buff, _T("%u mb free for caller, %u total mbytes, %u total free mbytes"),
lFreeCaller.QuadPart >> 20 , lTotBytes.QuadPart >> 20, lTotFreeBytes.QuadPart>> 20 );
MessageBox(0, buff, _T("Info"), 0);
unsigned __int64 test1 = lFreeCaller.QuadPart;
unsigned __int64 test2 = lTotBytes.QuadPart;
unsigned __int64 test3 = lTotFreeBytes.QuadPart;
int mb1 = (test1 >> 20);
int mb2 = (test2 >> 20);
int mb3 = (test3 >> 20);
swprintf(buff, _T("%u mb free for caller, %u total mbytes, %u total free mbytes"), mb1, mb2, mb3);
MessageBox(0, buff, _T("Info"), 0);
Not sure why the first messagebox reports 0 MB and the second shows 15 MB for Total number of bytes, but Im sure you can investigate that further if you're interested in that value.
HTH
“Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002
|
|
|
|
|
Hi
Here's what i'm trying;
I have a DLL from which I have exported a set of classes. I have 2 generic classes; say CCat and CCats (Simple Classes).
In CCats class i have a pointer to an object of the CCat class (CCat *m_pCatsCollection). CCats is supposed to maintain a collection of classes. So in the "Initialize" member function of CCats class i dynamically allocate memory in this fashion;
m_pCatsCollection = new CCat[10] // to store 10 cats.
Now, in the destructor of the CCats class i'm freeing the memory in this fashion;
if(m_pCatsCollection) {
delete []m_pCatsCollection; m_pCatsCollection = NULL;
}
I'm using this DLL to populate contols in a MFC exe!
If I put this in the destructor its crashing, and it unpredictable, i.e. sometimes it crashes sometimes it hangs, sometimes it works fine. I even tried freeing individual CCat object memory in a for loop it does not work. I even had a Release member function to do this, but that also doesnt work.
Am i doing something wrong, i dont know why this is happenning. Is there any problem in allocating and freeing memory in a Class exported in a DLL.
If I comment out the above code of delete then everything works fine, but i know i'm not freeing memory.
I also tried using the STL "list" template class to do this, using list::push_back to insert objects and list::clear to delete all objects but still its not working, i'm just not able to free memory in the destructor of the CCats Class.
Pls Help!
Anand
Anand Vinod
|
|
|
|
|
Anand Vinod wrote:
I'm using this DLL to populate contols in a MFC exe
Did you create this DLL as an MFC extension DLL? I never experienced such a thing, but all my DLLs are created as MFC extensions...
|
|
|
|
|
Hi João,
Thanks for the reply. I've not made my Dll an MFC extension DLL since i'm not using any MFC classes in the dll. But shud this cause a problem.
Anand
|
|
|
|
|
Hi Anand,
Looking at your code, I could see nothing wrong. I have written code for DLLs where such allocations and deallocations were being made and I never had a similar problem. I suspect (never checked it) that MFC may use its own operator new and, by not using an MFC extension DLL, you might be exposing yourself to an allocation nightmare. I would suggest to try this code in an MFC extension DLL and check the results. That's my best guess so far.
Good luck!
João Paulo
|
|
|
|
|
Well, I think my recent post might actually be a good starting point. You see, MFC does redefine operator new in afxmem.cpp. Looking at the code you can see that there are special provisions for when you are using MFC in a shared DLL. As a matter of fact, operator new is implemented in the MFC DLL (if you are using it at all). So this might be the source of your problems: your app is using one operator new and your DLL is using another...
|
|
|
|
|
If I add a date time picker to my dialog resource for my property page the dialog fails to get created. If I create a standard dialog it all works fine. Any suggestions?
Joshua Guy Sonork ID: 100.9944
ICQ: 519642
Hotmail: JoshuaJGuy@hotmail.com
|
|
|
|
|
Yes. It's twisted. You have to create it yourself. See my (unrelated) article A File Open Dialog for the PocketPC 2002[^]. Here, in the sample code, you will find two classes: CExDialog and CExDlgEngine . The last is intended to be used as a means to implement common functionalities in both CDialog and CPropertyPage -derived classes. The method you want to use is CreateDateTime . To use it, replace your date time picker with a static control with the same size and ID. In your OnInitDialog use this method like:
CreateDateTime(this, m_dtcDate, IDC_DATE, DTS_SHORTDATEFORMAT);
Where m_dtcDate is declared in your property page class as a CDateTimeCtrl .
Voilá!
|
|
|
|
|
I had a feeling you would probably be the one to answer.
Joshua Guy Sonork ID: 100.9944
ICQ: 519642
Hotmail: JoshuaJGuy@hotmail.com
|
|
|
|
|
I am looking for any help for creating a Multi-Column List Control with some columns to be check boxes. We need this for HPC 3.0 or HPC 2000 and for each field to be editable by just tapping on the field position by the row/column position. Please advise.
thank you
|
|
|
|
|
I'm having trouble implementing CompareItem for a Combobox. I've never used this before. Is there some code samples on how to implement this.
Thanks
|
|
|
|
|
I have spent almost 2 days trying to create a simple csv file that I can import into Excel. But I am having trouble with UNICODE. This is very simple to do in regular VC++ for desktop PC's, but how do you generate a CSV file using eMbedded VC++? Excel, on my desktop, does not like the CSV file generated from my Window CE computer.
Paul Jahans
|
|
|
|
|
You have to translate from UNICODE into MCBS or ANSI. Check the WideCharToMultiByte API.
|
|
|
|
|
Make the first two characters of the CSV file you generate FF FE.
This is how a Unicode text file is identified.
FE FF is used on some OSes with the other byte ordering.
You'll see this if you look at the raw file contents that RegEdit generates when you do a registry export on Windows 2K.
|
|
|
|
|
I can not display 2 objects of the same type(ex:cedit, clistbox) on the same cwindow... but they are created!
|
|
|
|
|
Can you show the code? There should be no problem achieving that.
|
|
|
|
|
I am trying to create a CWindow over a CView but i'm getting a transparent interface
|
|
|
|
|
If I call GetSystemPowerStatusEx() right when the handheld gets turned on the BatteryFlag shows that it is charging but it is not. If I call it any other time it returns the current state. Any ideas why?
Joshua Guy Sonork ID: 100.9944
ICQ: 519642
Hotmail: JoshuaJGuy@hotmail.com
|
|
|
|
|
|
I'm using an html control in my Smartphone2002 application as an output window (so html formatted text is continually being written to it)
My problem is that the control sometimes seems to wait for 3 or 4 lines to be "written" before updating it (which isn't much use when I want a real time update)
Is there something I need to do to force the control to always refresh as soon as I add the text?
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
You have to send a DTM_ENDOFSOURCE message to make sure that the text is complete. I think that you are depending upon a lateral behaviour of the control that is partially rendering your text. You have no control on its internal buffers and how they are flushed. So I think there is no "nice" solution to this problem.
|
|
|
|
|
Hmm, that was what I was suspecting.
Sadly I need to be able to continually update the text while the app is running. Sending the ENDOFSOURCE message means that the control no longer accepts any more input
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
benjymous wrote:
Sending the ENDOFSOURCE message means that the control no longer accepts any more input
Maybe you can work around it. Here is an idea: Set up a buffer where you will add the HTML text. Whenever you have a new text insertion, append it to your buffer, flush the control, and set its contents from the buffer. Maybe you can even try and control the vertical scrollbar, so that the lastest text is always displayed. If you want to avoid flickers, try SetRedraw .
|
|
|
|
|
Yeah, I think that's what I'm going to have to do.
There's an option to jump to a specific anchor, so I'll just write my buffer, followed by an anchor line to the control each time, then jump to that
--
Help me! I'm turning into a grapefruit!
|
|
|
|