|
|
Hi David,
when i see your question i remember my question in many years ago i wanted to got all detaily computer Memory(size,speed,bus,...)Motherboard(serial number,bios,cmos....) and i tried about 5 months but in the end i couldnt any helpful thing (i think you can remember DOS and Assembly).I used Win32_PhysicalMemory for got Capacity but not all previous,but your problem i am wondering i try with C# of course its differ with VC++ (a ManagementScope then ObjectQuery("Select * FROM Win32_PhysicalMemory") and .....)
but i cant get Status,Speed and manufacture,...) but for capacity or Name and some things its working like VC++ then i tring with VC++ but it seems that result is same with C# and i think your code not problem but i think it needs to a additional code then i starting to search on internet a big search and i see about 50 site but in these sites all users has same error with you they cant get BankLabel (of course we have this parameter) InstallDate,Manufacturer,HotSwappable,Model,PartNumber and ... if we want use another WMI we can use from Methods but in Win32_PhysicalMemory we dont have any methods and almost more examples are in C# or VB like(http://www.dx21.com/SCRIPTING/WMI/SUBCLASS.ASP?CID=32)
if you see this site 12 or 15 lines a declare a root a query and in the loop read items but i cant find any good C++ code for you for example in this link http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21214650.html) you can a problem Win32_PhysicalMemory(C++) and it seems that he find his problem
maybe it is some helpful to you
|
|
|
|
|
I would recommend you the following samples:
I hope they are helpful.
|
|
|
|
|
Thanks for your help, but how can I get your recommended samples linking? You can provide them to me? Thanks.
David
|
|
|
|
|
I have an application which calls the functions of a DLL. If control goes to that DLL i can not maximize my application. it simply hangs. then i need to END-TASK the application. Here i want to increase the priority of SC_MAXIMIZE message. How can i do it? please help me
JITEEN
|
|
|
|
|
Hi,
I think you don't need an increased priority, you only need a DLL without a deadlock!
Or if you havn't a deadlock, you need multithreading.
Your problem is, that your application-main-thread can't process the message-loop, if he is running (and blocking) at the DLL.
HTH
Frank
|
|
|
|
|
So here, i need to UI thread. Or the DLL's function which i m calling needs to be in thread? i mean what i should do exactly.
Jiteen
|
|
|
|
|
helpcode wrote: en i need to END-TASK the application. Here i want to increase the priority of SC_MAXIMIZE message. How can i do it? please help me ..
actually your main thread is calling the Function Thread, which seems to performing long function.. thats why it making the main thread hung!.. so better you try MultiThreading program! for that you have to implement some callback mechanism for same!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
The UI looks hung because messages have to actually be processed by the UI thread. While the thread is running code in the DLL, it's not processing messages in the queue. Changing to a multi-threaded design is often the best way to solve this problem.
|
|
|
|
|
hi all,
i am having one problem with threading
i created one dialog based application whose work is to read the data from serial port and display it.so i created one thred for this work.
means now i got two threads one is application thread and other is serial communication thread which is created in OnInitDialog.
now everything is working i mean the thread got created it read some bytes
from port and now it wants to show the data so need to send this data to main
thread. so i am doing this with ::SendMessage() but it is giving access violation. i don't know why this is happening and currently i am not sending the data also i.e. buffer so please help me
below is code (stepwise)
1)In Oninitdialog
THREADPARAM *ptp = new THREADPARAM;
if(ptp)
{
memset(ptp->array,0,30);
strcpy(ptp->array,"Harshal");
ptp->appHandle = this->m_hWnd;
hSerialThread = CreateThread( NULL,
0,
(LPTHREAD_START_ROUTINE) SerialCommunication,
(LPVOID) NULL,
0,
&dwSerialThreadID);
}
2)Thread function
UINT SerialCommunication(LPVOID pParam)
{
int write_req=0;
THREADPARAM *ptp = (THREADPARAM *)pParam;
while(1)
{
if(write_req == 2)// send write request and read it
{
DWORD length=0;
DWORD dwRead=0;
if (WriteFile(hCom,
SEND_CMD, // pointer to data to write to file
NOOFBYTE, // number of bytes to write
&length, // pointer to number of bytes written
NULL) == 0)
{// write failed
write_req = 0;
continue;
}
// writefile succeeded issue readfile
char buffer[MAX_MESSAGE];
memset(buffer,0,MAX_MESSAGE);
if (!ReadFile(hCom, buffer, MAX_MESSAGE, &dwRead, NULL))
{
write_req = 0;
continue;
}
if(dwRead > 0)
{
//MessageBox(NULL,buffer,"Data with packet",MB_OK);
::SendMessage(ptp->appHandle,MY_SHOW_DATA,0,0);// error is here
}
write_req = 0;
}
else // only read from port and increment counter
{
DWORD dwRead=0;
char buffer[MAX_MESSAGE];
memset(buffer,0,MAX_MESSAGE);
if (!ReadFile(hCom, buffer, MAX_MESSAGE, &dwRead, NULL))
{
write_req++;
continue;
}
if(dwRead > 0)
{// you are in thread you need to send message to
// main application
//char a;
HWND hwnd = (HWND)AfxGetApp()->m_pMainWindow;
::SendMessage(ptp->appHandle,MY_SHOW_DATA,0,0);
//MessageBox(NULL,buffer,"Data without packet",MB_OK);
}
write_req++;
}
}
return 0;
}
3) Sent message function
LRESULT CReadDataDlg::OnShowDataMessage(UINT wParam, LONG lParam)
{
return 0;
}
Thanks and regards
Harshal
|
|
|
|
|
harsha_1234 wrote: ::SendMessage(ptp->appHandle,MY_SHOW_DATA,0,0);
Use PostMessage() instead of SendMessage.. and look for difference between PostMessage and SendMessage in MSDN!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
From the 'serial port reader' thread I would place the data into a thread-safe queue of some sort and notify the 'display' thread that new data is available. The 'display' thread can pull it out of the queue and format as appropriate.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Hi, I am reading some float value from a file.
Code:
char tScaleLow[8],tScaleHigh[8],tAlarmLow[8],tAlarmHigh[8];
cfTag.Read(tScaleLow,sizeof(float));
cfTag.Read(tScaleHigh,sizeof(float));
cfTag.Read(tAlarmLow,sizeof(float));
cfTag.Read(tAlarmHigh,sizeof(float));
This is my code it reads the value fine.But the drawback is it reads only 4 characters i.e, if ScaleHigh is 100000 it reads only 1000.
So, i changed the code as follow...
float fScaleLow,fScaleHigh,fAlarmLow,fAlarmHigh;
cfTag.Read(&fScaleLow,sizeof(float));
cfTag.Read(&fScaleHigh,sizeof(float));
cfTag.Read(&fAlarmLow,sizeof(float));
cfTag.Read(&fAlarmHigh,sizeof(float));
This reads some garbage value like 6.002e+102 like this,all the four things reads like this.
Whats the wrong in my code?Or is there any way to read all values in that previous code.
Anu
|
|
|
|
|
Anu_Bala wrote: reads only 4 characters
That's because you are passing the sizeof(float) which is 4 on windows platform.
The second parameter for Read() - The maximum number of bytes to be read from the file. This is four and so it reads four.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Yes,
Any solution for this?
Anu
|
|
|
|
|
After each value that you write in a file put a comma ',' as a delimiter.Split the string of the file based on that ','.
Another option would be to read and write the full structure at a time and get/set the values in the file.(Use fread in this case)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Can u tell me why its not read in this code..
float fScaleLow,fScaleHigh,fAlarmLow,fAlarmHigh;
cfTag.Read(&fScaleLow,sizeof(float));
cfTag.Read(&fScaleHigh,sizeof(float));
cfTag.Read(&fAlarmLow,sizeof(float));
cfTag.Read(&fAlarmHigh,sizeof(float));
its read the wrong value..
Pls..
Anu
|
|
|
|
|
As it seems, the value in the file is a string.
If that is the case (and cfTag.Read is a functions to read a string from a file into a given char array), you are using it wrong. You should probably use something around the lines of (thats a guess):
char tScaleLow[TSCALELENGTH]; and<br />
cfTag.Read(tScaleLow,sizeof(char) * TSCALELENGTH);
Actually, without a definition of cfTag.Read, there is no way to tell what you are doing wrong, but I really suspect wrong use of "Read" to be the reason.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Hi all,
I hope you can give me a hint or help about a debugging issue.
Out of a minidump I got from a release build, the problem showed as follows:
The stack in VC++ debugger when opening the .dmp file, showed:
0x00000000
and nothing else. EIP of course also contained NULL.
I then looked at the ESP address to see the stack. There I found the jump-back address to see where the code would continue if the jump that now occurred to 0x00000000 would have been successful.
The C++ code there looks like the following:
if (variable && variable->SomeFunction() && .....)
"variable" is a pointer to an object of a class.
The question now is, how can I debug that further. Did "variable" maybe not contain - for some reason - a pointer to an object of the class it should point to where the offset to ->SomeFunction() would be NULL ?
Any idea how, for the next iteration of the release software, some code could be added to give more information about the problem - if it still crashes there ?
Thanks for any help,
Manfred
|
|
|
|
|
|
Well, I guess this won't help me when the EIP actually jumped to 00000000
I used the PDB anyway which got me enough information to find the code where the offending jump occured.
icke
|
|
|
|
|
Hi all,
all the links that appear in CRichEdit Ctrl are based on the window scheme i am using.
is there a way to tell the rich edit that all my link will apear in a blue color regardless the window scheme i am using?
thanks in advanced
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Hi all,
i play a sound using:
PlaySound(MAKEINTRESOURCE(IDR_WAVE),AfxGetInstanceHandle(),SND_PURGE | SND_RESOURCE | SND_ASYNC);
i stop this sound using:
PlaySound(NULL,AfxGetInstanceHandle(),SND_PURGE | SND_RESOURCE | SND_ASYNC);
But when i call the above line again (PlaySound with NULL), the sound is being played again
is there a way to avoid this problem?
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
If you run PlaySound(null,SND_PURGE); whats happen?
|
|
|
|
|
you mean exactly as you wrote? hmm didn't give it a try , will do and let u know
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|