|
Richard ,
I do not follow your explanation.
In this MSDN doc the second parameter is defined as const GUID*.
Am I using wrong version ot the Setupapi.h?
PS Did you read the title? I did say compiler error.I do appreciate your help, but growing little tired of your sideline remarks,that's all.
http://msdn.microsoft.com/en-us/library/windows/hardware/ff551074(v=vs.85).aspx
BOOL SetupDiGetClassImageIndex(
_In_ PSP_CLASSIMAGELIST_DATA ClassImageListData,
_In_ const GUID *ClassGuid,
_Out_ PINT ImageIndex
);
|
|
|
|
|
Vaclav_Sal wrote: _In_ const GUID *ClassGuid,
The pointer is a constant, not the structure.
|
|
|
|
|
Oh come on man, it is the C language. If the compiler bitches just cast it out. YOU are in control. YO are the master!
|
|
|
|
|
Have you tried something like this:
GUID tmp(GUID_DEVCLASS_COMPUTER);
b = SetupDiGetClassImageIndex(&m_imgList, &tmp, &nRootImg);
|
|
|
|
|
Hi,
I tried to port the fork API in Linux to Windows (Windows 7 and Windows 8) using the native API RtlCloneUserProcess as discussed in the following link.
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/afdf1b68-1f3e-47f5-94cf-51e397afe073/
With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc. The solution is to inform the CSR /win32 subsystem about the new process. But I could not able to do that. Please help me to re link the child process to the CSR.
|
|
|
|
|
How do you declare a TBYTE in C and declare a pointer to a location to be used as a TBYTE? I know how to do it in MASM, but how do you do it in C?
Dave.
|
|
|
|
|
This should help you:
typedef unsigned char tbyte[10];
int main()
{
tbyte a;
a[0] = 3;
return 0;
}
The drawback is it doesn't initialize the array for you.
My 2 cents: Please don't mix different languages' idioms. Each language is meant for a different purpose.
If you need to, you can easily use assembly. VC++ supports inline assembly. Otherwise, you can write a separate asm file and then link the resulting object file to your exe.
|
|
|
|
|
manoranjan,
I didn't think about using a typedef. I understand how to use in-line assembly, but without the typedef, trying to do
fld tbyte ptr var
fails.
Thank you for the answer.
I have re-written ENT in MASM to try to speed it up for huge files. I first modified ENT to handle the huge files, but it was terribly slow (for my 16 GB file). It took 32 minutes to process. I have cut that down to 10 minutes with my entmasm, and I am trying to validate the calculations by using printf statements in both to display all of the calculation inputs and outputs (for a VERY SHORT 10 BYTE file), but in the entropy calculations, the results do not quite match. The C compiler (visual Studio 2008) is optimizing the code and keeps most of the intermediate results on the FPU stack in temporary real format. My masm code was pretty brutal and kept each calculation separate, saving results in memory. I was using doubles (real8) for storage, and I think that the loss of precision when saving an FPU value as a real8 is what caused the result differences. I will convert my masm code to use tbytes and modify the ENT C code to do the same, and see if that makes the results match.
One other question. ENT has several 256 entry arrays for the counts and probabilities. If I change these arrays of 256 tbytes (10 BYTES each), will the mod 16 mis-alighment cause performance problems? Would it be better to make them arrays of owords (16 BYTES) and just index by 16 instead of by 10? I am not worried about the extra memory, I have GIGA BYTES of unused memory.
Dave.
|
|
|
|
|
Yes, misalignments cause performance issues on x86 (and seg fault on ARM processors).
Speaking of performance... also consider fitting your data structure (by padding) in a CPU Cache Line. This should also improve performance.
Finally, a (stupid?) question from me: What is ENT?
|
|
|
|
|
manoranjan,
I have already implemented the DQWORD arrays for my MASM version, and am adding printf statements of intermediate calculations. The change to use TBYTES did fix the differences I had seen in the calculated ENT value between the C version and my MASM version. This was not as simple as it looked to be at first. The only FPU instructions than can use TBYTES are FLD and FST. You cannot use FADD TBYTE PTR [i], but I can see where the xxxP FPU instructions come from:
fld val1
fadd val2
fdiv val3
This had to be changed to:
fld val1
fld val2
faddp
fld val3
fdivp
It turns out that this is exactly what the FPU needs to do for an faddd val - it must push the stack, load the double/float/integer into st0 and convert it to temporary real, then add/sub/mul/div ST(1) by ST(0) and put the result into ST(1), then pop the stack leaving the result in ST(0). With TBYTES you just have to do it manually, - BUT - The FPU doesn't have to do any conversions - the TBYTE is already in temporary real format and can contain a signed QWORD (63 bits, + sign). Unfortunately, the FPU cannot handle unsigned 64 bit values (they end up as negative values).
See here for ENT: [^]
The biggest improvement I got was changing from fgetc for each character to reading 65536 bytes into a buffer (with no system buffering) and indexing through the BYTES, then reading more from the file into the buffer and processing. Another interesting change was to fill the buffer, initialize one time for the FIRST character, then skip to process the characters, skipping around the subsequent re-fill buffer entry point. So little extra code, BUT, avoided checking if this was the first character 16 billion times as was done in ENT. Another speedup was to fragment the character occurrence buffer - I had to grow the collection bins to a QWORD for supporting a max file (2^63 BYTES), but in the BIT mode this increased the count to 2^66. I had to accumulate the counts in three DWORDS in a DQWORD, using "add value, adc 0, adc 0," but this occurred (in my 16 GB test) 16 billion times. With a smaller buffer that could contain the counts in a DWORD, it was just an "add value" for the buffer count, then 256 iterations of "add value, adc 0, adc 0," to accumulate the 256 occurrence values in the DQWORD array and clear the DWORD counts between buffer fills. Also for checking whether a bin had any count at all (several places in ENT checked this), I accumulated (at the end of the file processing) the 3 DWORDS for each entry into the fourth DWORD that could be tested with a single instruction.
But I digress from a simple C question into something more appropriate for Algorithms.
Dave
|
|
|
|
|
Thank you for sharing your experiences. Your project seems to be quite interesting!
Good luck
|
|
|
|
|
Hello Im currently doing a project in Visual Studio 2010 where I need to create a bank account with 5 tabs. on the first tab the user is to put their info in (name addres etc) and the balance they wish to deposit. The deposit cant be a negative number and the starting deposit "will be passed to the createAccount method" as stated in project outline. Im really lost in this class and dont know exactly how to do this. Im guessing it needs to have a method created for it because the balance can be adjusted with the withdrawls and deposits that can be made after the account is created and the deposits and withdrawls also need a method because the with draw will reduce the users balance in the "accountInto array" Im really really lost and if anyone can give me any guidance I would appreciate it!
|
|
|
|
|
Magda6347 wrote: Im really really lost You seem to be starting at the wrong place for this question. Start by thinking about what information you need to maintain in your class and what operations you need to perform during its lifetime. Take a look at this documentation[^], or if you have a decent reference manual handy, go to the classes section in there.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
A good place to start is with the user interface. Just use the designer to add and position the controls where you want them. This is an easy step, but it clarifies what you need to do next.
The second step is to define handlers for the controls, e.g. a function that's called when the user clicks a button.
The third step is to define the variables to maintain the information your program will need, as Richard has suggested.
The next step is to implement the functions that process this information to give the desired results.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
You are so helplessly lost. You really need to start from basics and ask a specific TECHNICAL question, not some vague 'help me do my project for me' type question.
You want 'bank account method' help? Tell me, where is 'bank account' on a VS menu? DOes it exist? Do you want VS to think for you?
Here is some advise. Either give up programming or go back to square one and think, think REALLY carefully about what you want to achieve. Then come back and ask a question when you have one that is fully formed. (Oh, and when you have got a question FULLY formed that is worthy of asking, it will suggest its own solution.)
Sorry for being such a c*^t, but I am an arrogant bastard who has been programming all kind of complex stuff for so long I can not bear the ignorance that laziness brings.
|
|
|
|
|
No need to apologize I pity people like you who waste energy on trying to degrade people rather than help them.
|
|
|
|
|
I want to read text file into edit boxses
e.g 10 string present in a text file. I have 10 edit boxes on dialog. how i can read that 10 string into edit box?
Thanks.
|
|
|
|
|
|
I think first you should add a button in dialog and on handle of this button write the code below
void CReadFileDlg::OnReadFile()
{
CEdit* m_EditArray[10];
CStringArray FileArray;
char cTemp[256];
ifstream fin;
fin.open( _T("C:\\FileRead.txt"), ios::in|ios::nocreate );
while( !fin.eof() )
{
fin.getline( cTemp, 256, '\n' );
CString csChartoString;
csChartoString.Format( "%s", cTemp );
if( csChartoString != "" )
{
FileArray.Add( csChartoString );
}
}
int top = 10;
int bottom = 30;
for(int i = 0; i < 10; i++)
{
m_EditArray[i] = new CEdit;
DWORD dwStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
m_EditArray[i]->Create(dwStyle, CRect(10,top,100,bottom), this,100+i);
m_EditArray[i]->ShowWindow(TRUE);
top += 30;
bottom += 30;
}
int nArraySize = FileArray.GetSize();
int nPos = 0;
for( int nIdx= 0; nIdx < nArraySize; ++nIdx )
{
m_EditArray[nIdx]->SetWindowText( FileArray.GetAt( nIdx ));
}
}
|
|
|
|
|
<b>In process / progress of being solved</b>
WM_DEVICECHANGE sets wParam to DBT_DEVNODES_CHANGED to update list (tree?) nodes.
No other info is available then. I have not retrieved any device list, so it is useless for me.
To receive DBT_DEVICEARRIVAL it is necessary to first use RegisterDeviceNotification.
At this point no other help is required.
Thanks
Vaclav
I need some help / hints with implementing WM_DEVICECHANGE in MFC Document /View setup.
I have managed to intercept the WM_DEVICECHANGE in CmainFrame message map and process it .
The problem m is that the wParam is nowhere near the 0x8xxx, but it is plain “7” and the lParam is 0.
I went thru the Dbt.h and cannot figure out what is the wParam = 7 telling me.
Here is the code snippet and if it is not formatted to you liking – I am sorry , but I write my stuff in OpenOffice and than copy it to CodeProject so it cannot be formatted properly.
<b>I just need some troubleshooting pointer / suggestion how to analyze these mysterious parameters. </b>
Maybe CmainFRame is not the place to start, but I got same parameters values when I used Cdialog message map directly.
Any help is as always appreciated.
Cheers
Vaclav
ON_MESSAGE(WM_DEVICECHANGE, OnMyDeviceChange)
bool CMainFrame::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)
{
TRACE("\nLRESULT CMainFrame::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)");
TRACE("\nwparam %i ",wParam);
TRACE("\nlParam %i ",lParam);
AfxMessageBox("!!!! CMainFrame::Device detection ");
// pass WM_HARDWARE to view
GetActiveView()->PostMessage(WM_HARDWARE,wParam,lParam);
….
Addendum
JUst found this info, so the additional question is - is CMainFrame "top window" and if not will RegisterDeviceNotification solve this ? I shall try it next.
The DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE events are automatically broadcast to all top-level windows for port devices. Therefore, it is not necessary to call RegisterDeviceNotification for ports, and the function fails if the dbch_devicetype member is DBT_DEVTYP_PORT.
|
|
|
|
|
It is the DBT_DEVNODES_CHANGED[^] event.
Your code and text can be formatted properly. It must be done manually after pasting (it does not care if pasting from OpenOffice or a plain text editor but you should remove HTML tags when pasting from Ooo). Select text with mouse and use the buttons above the edit window to apply specific formatting. If you know HTML, you may also type the HTML tags. Check the preview to see how it looks.
|
|
|
|
|
See here [^]about halfway down.
From MSDN: DBT_DEVNODES_CHANGED
A device has been added to or removed from the system.
|
|
|
|
|
Thank you, obviously I have not look all the way to the end of the page!
However, what the dickens is " ring3 people" note talking about?
So when "new node is detected / chaged" is not same as
DBT_DEVICEARRIVAL A device has been inserted and is now available.
Mr MS - I am not sure this note is in English!
and to get the device more work is necessary???
I am not sure I can figure that out, getting tired of this USB mess.
/*
* Message = WM_DEVICECHANGE
* wParam = DBT_DEVNODES_CHANGED
* lParam = 0
*
* send when configmg finished a process tree batch. Some devnodes
* may have been added or removed. This is used by ring3 people which
* need to be refreshed whenever any devnode changed occur (like
* device manager). People specific to certain devices should use
* DBT_DEVICE* instead.
*/
#define DBT_DEVNODES_CHANGED 0x0007
|
|
|
|
|
Vaclav_Sal wrote: I write my stuff in OpenOffice and than copy it to CodeProject so it cannot be formatted properly. Of course it can be formatted properly, just select all the code and use the code link above the edit window, or manually put a <pre lang="c++"> tag in front of it, and a </pre> tag at the end.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thank you, you are right.
Vaclav
|
|
|
|
|