|
the "variable =" and the "value =" are not on the same lines. To say the the truth, I'm using snmputil to get the MIBS of the signal strength of an AP. And the signal strength is "-44". so I was trying to extract the signal strength and put it into another file for reading.
but I'm not sure how to get rid of the first line which is the "variable =" line.
Currently, there's only one integer variable in the text file, it's such a pity tht I cannot attach the text file here but it's the same as the one coded.
sorry, I don think I'll use MFC, but to stick with C/C++ prog. Thanks for any help!
|
|
|
|
|
When you read a line from the file containing "Value =", just skip to the 19th position of that line and read the remainder of it as an int .
Another option might be to skip to the end of the file, go backward 3 bytes, and read the integer from there.
Of course these will fail in many different ways, but since you did not provide any other requirements or constraints, better solutions were withheld.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Do u mean tht I should try to use a method to find "value =" then frm there read the integer value of -44? I'm not sure if this works but I'm gonna try and I'm not even sure if I can try successfully or not cos I nv tried it b4 and my prog skills sux..haha! But thanks for ur reply!
|
|
|
|
|
Cabomba wrote: Do u mean tht I should try to use a method to find "value ="...
Well, if there are only two lines of text in your file, you don't even need to do that. The first line can be read and just discarded.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for ur reply but how do I "ignore" the first line after it is being read? Or how do I discard it?
|
|
|
|
|
How do you ignore any value/variable? Just don't use it. Read the first line from the file. Read the next line from the file. Voila! The firt line has been ignored.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Tried downloading a file on a specific location in a Non-proxy environment using InternetOpenURL() and InternetReadFile() API's. This worked fine.
But when i try the same in Proxy Environment it fails. I tried doing HttpQueryInfo() and then checking the status for HTTP_PROXY_AUTH_REQD. This is successful but when i set the username and password for Proxy Authentication and retry, it still gives me status as HTTP_PROXY_AUTH_REQD. If I continue downloading the file then junk characters are downloaded and written to the file.
Need help to make InternetOpenURL work in a Proxy Environment. (Please note that Proxy Server Details are not present with my application and i cannot bypass the Proxy Server)
Thanks in advance.
Ravi.
|
|
|
|
|
Hi all,
May I know how to calculate the number of times a character occurs in a string? Are there any function returns the number of times a character occurs in the string?
Thanks.
Regards,
littlecheer
|
|
|
|
|
Made function, no AFAIK. But you can code it quite easy. Take the String as a vector and make a for with an if and a counter. When you find the character... +1, when not... next element.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Like this:
std::string str("this is a test string only");
int num = std::count(str.begin(),str.end(),'a');
Remember:
#include <string>
#include <algorithm>
|
|
|
|
|
Like this:
std::string str("this is a test string only");
int num = std::count(str.begin(),str.end(),'a');
Remember to include string and algorithm
|
|
|
|
|
hi,
I want to run only single instance of my application like
windows media player . can any one told me how it is possible
Trioum
|
|
|
|
|
One of the ways in to create an inter process Thread Syncronisation object like semaphore and lock it when you start the application and unlock before exit.
Saadhinchaali
|
|
|
|
|
Use a named mutex...
HANDLE hMutex = CreateMutex( NULL, FALSE, _T("MY_UNIQUE_MUTEX_NAME") );
if ( WaitForSingleObject( hMutex, 0 ) != WAIT_OBJECT_0 )
{
CloseHandle( hMutex );
// failure case -- someone else already owns it.... (my other instance?)
exit here!
}
.... run program
ReleaseMutex( hMutex );
CloseHandle( hMutex );
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
There is more than one article on codeproject on how to do this.
Search for singleton, single instance, etc.
Iain.
|
|
|
|
|
trioum wrote: can any one told me how it is possible
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I like to create a out of process(seperate application) webbrowser from one applicationa and want to control this webbrowser from the main program.
Any idea or link would be very helpful?
Thank you.
|
|
|
|
|
The are a lot of ways of course.
You may use a form of Interprocess Communication http://msdn2.microsoft.com/en-us/library/aa365574.aspx[^]
or you can build a COM out-of-process server (COM is a rather big topic however).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
hi all,
I am using ORCA to validate the product key in C# 2005 windows application.
i am using the following C++ code in a dll to be added to the MSI for validation.
UINT __stdcall ValidateSerial(MSIHANDLE hInstall)
{
TCHAR szPidKey[PIDKEY_LENGTH];
DWORD dwLen = sizeof(szPidKey) / sizeof(szPidKey[0]);
///retrieve the text entered by the user
UINT res = MsiGetPropertyA(hInstall, _T("PIDKEY"), szPidKey, &dwLen);
if(res != ERROR_SUCCESS)
{
//fail the installation
return 1;
}
bool snIsValid = true;
//validate the text from szPidKey according to your algorithm
//put the result in snIsValid
//the template we use is <###-####> = <xyz-abcd>; # digit between 0 and 9
//the algorithm is very simple (XY * Z + 7) * 13 = ABCD / 2
int xy = DIGIT(szPidKey[0]) * 10 + DIGIT(szPidKey[1]);
int z = DIGIT(szPidKey[2]);
int left = ((xy * z + 7) * 13 ) * 2;
int right = DIGIT(szPidKey[4]);
right = right * 10 + DIGIT(szPidKey[5]);
right = right * 10 + DIGIT(szPidKey[6]);
right = right * 10 + DIGIT(szPidKey[7]);
snIsValid = (left != 0) && (right != 0) && (left == right);
TCHAR * serialValid = NULL;
if(snIsValid)
serialValid = _T("TRUE");
else
{
//eventually say something to the user
::MessageBox(0, _T("Invalid Serial Number"), _T("Message"), MB_ICONSTOP);
serialValid = _T("FALSE");
}
res = MsiSetPropertyA(hInstall, _T("SERIAL_VALIDATION"), serialValid);
if(res != ERROR_SUCCESS)
{
//fail the installation
return 1;
}
//the validation succeeded - even the serial is wrong
//if the SERIAL_VALIDATION was set to FALSE the installation will not continue
return 0;
}
but when i execute the above code, i am getting the following error.
error LNK2019: unresolved external symbol _MsiSetPropertyA@12 referenced in function "unsigned int __stdcall ValidateSerial(unsigned long)" (?ValidateSerial@@YGIK@Z) CustomAction.obj
i have included <msi.h> and <msiquery.h>
I am a beginner in VC++ and could anybody help me with some suggestions
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
how to copy a dialog from one project to other project? I want to reuse the existing dialog present in one project to a new project whioch i am working on. Can any one help me out in solving this.
Naveen
|
|
|
|
|
Open .rc file in IDE and just copy and paste will do.
Regards,
Paresh.
|
|
|
|
|
Paresh.... What my problem is that I have 4 dialogs in my existing project and i want only one in that four for reuse in my new project. How could i do this ? Help me out.
|
|
|
|
|
u require the design and code or only design?
|
|
|
|
|
I want only design and not code.
|
|
|
|
|
then its simple...
u should be having the rc file of the old application. drag that to the new applcation. since ur application will be minimised just need to drag and position it on top of the new application. dont drop it. once it loads the page automatically maximises. then drop it. copy the design close the rc file and paste the design...
hope u understood.
|
|
|
|