|
many thanks
It sounds great. I gonna try it and let you know the results.
|
|
|
|
|
For very large files (millions of lines) this will still take a while. Seeing how the file is sorted by date and time I would use your original idea of using CFile::Seek to do a binary search of the file. A binary search will be slower if the required data is right at the start of the file, but a heck of a lot faster if the data is anywhere else.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
PJ Arends wrote: Seeing how the file is sorted by date and time...
Was that a guarantee? If so, then a binary search via Seek() is the way to go.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If it is not sorted a sorted solution would likely be optimal for 4 million records. Either sorting the orginal file or creating and index file or memory based index, perhaps a Database should be considered.
led mike
|
|
|
|
|
Many thanks for your solutions.
I think that your idea of using strncmp(p, "20000104\t0900", 13) == 0) in a binary search is a good answer.
I'll try it right now.
thnks again
|
|
|
|
|
Thnks for this solution.
yes the file is sorted by date and time so Binary search is a good answer to my question.
thnks again
|
|
|
|
|
I have a two-bay SCSI case, each with separate Target ID.
Running code that utilized SCSI_PASS_THROUGH_DIRECT reads works fine when only one disk is seated in the drive, but when both disks are seated, I'm getting errors on the reads. Any ideas?
Thanks,
Jim
|
|
|
|
|
hi i am using wmi concept to get the adapter details. i passed query to win32_networkadapterconfiguration as hres = m_pSvc->ExecQuery( bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE SettingID = AdapterIndex"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&m_pEnumerator);
the value fo adapterindex is 9; but its returning as hres failed. how to pass the value of the variable n query
|
|
|
|
|
How about something like:
char szQuery[128];
sprintf(szQuery, "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE SettingID = %d", AdapterIndex);
ExecQuery(bstr_t("WQL"), szQuery, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &m_pEnumerator);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes i got it. but how to get ipaddress and subnet from wmi. i am getting as 1and 2 respectivly
|
|
|
|
|
saisp wrote: but how to get ipaddress and subnet from wmi.
I use:
IWbemServices *pService = NULL;
IEnumWbemClassObject *pEnum = NULL;
...
HRESULT hr = pService->CreateInstanceEnum(_bstr_t("Win32_NetworkAdapterConfiguration"),
WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY,
NULL, &pEnum);
if (WBEM_S_NO_ERROR == hr)
{
IWbemClassObject *pClass = NULL;
ULONG ulReturned;
hr = pEnum->Next(WBEM_INFINITE, 1, &pClass, &ulReturned);
if (WBEM_S_NO_ERROR == hr)
{
_variant_t v;
hr = pClass->Get(L"IPAddress", 0, &v, NULL, NULL);
if (VT_NULL != v.vt)
{
LONG lBound;
BSTR Value;
SafeArrayGetUBound(V_ARRAY(&v), 1, &lBound);
while (lBound >= 0)
{
SafeArrayGetElement(V_ARRAY(&v), &lBound, &Value);
TRACE("IPAddress[%u] = %S\n", lBound, Value);
lBound--;
}
}
hr = pClass->Get(L"IPSubnet", 0, &v, NULL, NULL);
if (VT_NULL != v.vt)
{
LONG lBound;
BSTR Value;
SafeArrayGetUBound(V_ARRAY(&v), 1, &lBound);
while (lBound >= 0)
{
SafeArrayGetElement(V_ARRAY(&v), &lBound, &Value);
TRACE("IPSubnet[%u] = %S\n", lBound, Value);
lBound--;
}
}
}
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hmm but how to know the ipaddress value. i have to print it in a file. sorry for disturbing you. its working fine but i cant see the value (192.168.168.168)
|
|
|
|
|
saisp wrote: hmm but how to know the ipaddress value.
That's what my code snippet was for.
saisp wrote: its working fine but i cant see the value...
These two statements contradict each other.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Means no error but i cant get the value. how to print the ip address value. you have used TRACE. i dont know how to get ip and subnet value from this. as im new to this i got many doubts.
|
|
|
|
|
saisp wrote: you have used TRACE. i dont know how to get ip and subnet value from this.
Are you not familar with printf() ? It's contained in Value .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes i tried fprintf to print in the file. but the value returned is 150012.
|
|
|
|
|
saisp wrote: yes i tried fprintf to print in the file. but the value returned is 150012.
fprintf() returns the number of bytes written to the file. Are you writing 150012 bytes to the file? Are you mistakingly trying to use %d or %u rather than %S ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
deeps_cute wrote: i tried to write the value of the variable "value".
Hint: Providing a code snippet of this would be helpful.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes here it is
variant_t v;
hr = pClass->Get(L"IPAddress", 0, &v, NULL, NULL);
if (VT_NULL != v.vt)
{
LONG lBound;
BSTR Value;
SafeArrayGetUBound(V_ARRAY(&v), 1, &lBound);
while (lBound >= 0) {
SafeArrayGetElement(V_ARRAY(&v), &lBound, &Value);
TRACE("IPAddress[%u] = %S\n", lBound, Value);
fprintf(fp,"%u", value); lBound--; } }
|
|
|
|
|
saisp wrote: fprintf(fp,"%u", value);
What is value ? If you meant Value instead, then you did exactly what I said not to and used %u instead of %S .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
deeps_cute wrote: no sir now also its printing the same value(150012).
Are you using the debugger to verify that the _variant_t and BSTR variables contain actual data?
deeps_cute wrote: i think i am irritating you
No, that is reserved for those that don't try.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes sir but its not returning the actual value. some address variables are there
|
|
|
|
|
|
sorry sir actually we r two members facing the same problem thats why such confusion. but till now we didnt get the solution. i am expectin mr.david or anyoe else for solving my problem. can you help me
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
It's a bit hard to follow the thread now that you have deleted the posts (
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|