|
Thank you for replying me!
I've never used this function before and I don't know how to use it!
By the way the program i'm making is in Win32 API!
How can I use it in here?... Please send an example!!
|
|
|
|
|
Mike Nordell wrote:
Every call to ReadFile goes to the system, forcing context switches for every call, while the std iostream functions perform user-land (in process) buffering.
Everything in the CRT eventually calls APIs to get their job done. fstream , fread() , fgets() et al all boil down to calls to ReadFile() .
--Mike--
PROCRASTINATION: Hard work often pays off after time, but laziness always pays off now.
BUY MY SOFTWARE!! (please?) RightClick-Encrypt - file encryption w/Explorer plugins | 1ClickPicGrabber - web page picture grabber for IE
My IntarWeb Homepgae!!!11
|
|
|
|
|
Michael Dunn wrote:
Everything in the CRT eventually calls APIs to get their job done. fstream, fread(), fgets() et al all boil down to calls to ReadFile().
Yes, but usually not every call forces this context switching by calling ReadFile. If dealing with plain-text and line-by-line input (which was the context here), it seems more than likely that only a very small percentage of iostream calls (to get/read data from the file) would actually result in system calls.
|
|
|
|
|
how can i use a .net dll in a c++ or mfc project?
thanks
|
|
|
|
|
A .NET assembly can be exported as a COM dll, by using the regasm.exe tool provided in the .NET SDK (or tlbexp.exe + regsvr32.exe). Once created and registered, the type library can be used like any other COM object.
[edit]Of course, the COM object itself is only an entry-point to the .NET EE. As a consequence you need to distribute the .NET run-time (dotnetfx.exe) along with your MFC app.[/edit]
|
|
|
|
|
I have the following code which will populate the list control from a recordset.
But it gives error and crashes .
Can anyone rectify the problem.
void CReport::OnGetdispinfoList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
// TODO: Add your control notification handler code here
CString szValue = "\0";
CDBVariant varValue;
long index = pDispInfo->item.iItem;
long subItem = pDispInfo->item.iSubItem;
if(pDispInfo->item.mask & LVIF_TEXT)
{
try
{
crs->SetAbsolutePosition(index+1);//Set the file to desired index
}
//<sql>
catch(CDBException* e)
{
AfxMessageBox(message += e->m_strError,MB_ICONEXCLAMATION );
e->Delete();
return;
}
try
{
if(subItem)
crs->GetFieldValue((short)subItem,varValue);
else
crs->GetFieldValue((short)0,varValue);
}
//<sql>
catch(CDBException* e)
{
AfxMessageBox(message += e->m_strError,MB_ICONEXCLAMATION );
e->Delete();
return;
}
const CDBVariant variant =varValue;
try
{
switch(variant.m_dwType)
{
case DBVT_SHORT:{ szValue.Format("%d", variant.m_iVal);
break;
}
case DBVT_LONG:{ szValue.Format("%d", variant.m_lVal);
break;
}
case DBVT_SINGLE:{ if ( variant.m_fltVal == 0.0 )
szValue = "Verify";
else
szValue.Format("%.1f", variant.m_fltVal);
break;
}
case DBVT_DOUBLE:{ if ( variant.m_dblVal == 0.0 )
szValue = "Verify";
else
szValue.Format("%.1f", variant.m_dblVal);
break;
}
case DBVT_DATE:{
szValue.Format("%B %d, %Y",variant.m_pdate );
break;
}
case DBVT_STRING:{ szValue = *variant.m_pstring;//szValue = V_BSTRT( &varValue );//convert BSTR to CString
break;
}
case DBVT_BOOL:{ if(variant.m_boolVal)
szValue = "TRUE";
else
szValue = "FALSE";
break;
}
case DBVT_UCHAR:{ szValue = (char*)variant.m_chVal;
break;
}
case DBVT_NULL:{
szValue = "Error";
break;
}
default:{
szValue = "\0";
break;
}
}//switch
lstrcpyn(pDispInfo->item.pszText, szValue.GetBuffer(szValue.GetLength()), pDispInfo->item.cchTextMax);//set item text
}
catch(CException *e)
{
TCHAR szCause[255];
AfxMessageBox(e->GetErrorMessage(szCause,255),MB_ICONEXCLAMATION );
return;
}
}// End of sorting
*pResult = 0;
}//OnGetdispinfoList1
|
|
|
|
|
How to Play the Images round the Ellipse or Circle?
|
|
|
|
|
hi i wanted to make a linked list in Visual C++ 6.0 , i had done it in c++ but cant do the same in VC. please help me.
i get a run time eror (memory acces error) when i use this code in Visual cpp
typedef struct str
{
int x;
str * next;
}a;
a * node=NULL;
node->x=0; // error occurs in this
|
|
|
|
|
Alright, I was going to respond with a smartass answer, but I won't. First of all, the code you've shown will indeed work if it's running on some special embedded device created by you. However, acessing the address of 0 (NULL) is usually a really bad idea (in usual circumstances, i.e. almost every operating system), and it's why most programmers set pointer addresses to zero when they initialize them: So it will cause a fault when you access an invalid address. So, what you need to do, is allocate your node pointer on the heap. Do this:
a * node = new a;
Don't forget to delete it when you are done with it:
delete a;
Also, since you are using C++, why not use the std::list? It would provide you with all the cool stuff like storage, traversal, etc.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
I am developing a application,which requiresMS Paint as external editor. But How to check MS Paint is present in system or not?.
|
|
|
|
|
Holy crap, I feel sorry for you.
|
|
|
|
|
LOL!
|
|
|
|
|
MS Paint is installed along with the operating system.
|
|
|
|
|
Just check if file "mspaint.exe" exists in system32....
BOOL FileExists(const char *pszPath)
{
if (GetFileAttributes(pszPath) != HFILE_ERROR)
return true;
return false;
}
|
|
|
|
|
Hi, everyone!
When using the following statement,
--------
#include <ntddk.h>
--------
in Win 2k and VC7.0, an error occurs,
"ntddk.h": No such file or directory.
How to resolve the trouble?
Thanks in advance,
George
|
|
|
|
|
I'm sorry, but if you cannot solve this problem on your own, maybe a mini-gateway is a little hard task for you.
Zoltan
Ps:
Check the include path (add NTDDK\inc and NTDDK\inc\ddk to the path)!
Zolee
|
|
|
|
|
Thanks, Zoltan buddie!
I can not find a folder named NTDDK on my machine.
Maybe I have something lost? Please help.
Cheers,
George
|
|
|
|
|
Download Device Drive Kit (DDK) from Microsoft[^] site.
A. Riazi
|
|
|
|
|
Hi, A. Riazi buddie!
I can not find the download page for DDK.
Can you point me the page?
Thanks in advance,
George
|
|
|
|
|
|
Thanks, Riazi buddie!
George
|
|
|
|
|
Hi, everyone!
I want to implement a mini-gateway on Windows platform.
Where can I get some sample codes for it? I need a gateway
that can implement basic functions, for example, check whether
a package from a certain IP address can pass through.
Thanks in advance,
George
|
|
|
|
|
I am using SetDialogBkColor to change the background color of our dialogs. Unfortunately CPropertySheet does not apply this setting. I have been able to change the property sheets background color via WM_CTRLCOLOR, but I can't seem to do this for the tab control embedded on the property sheet. I have tried subclassing the tab control, but I don't get WM_CTRLCOLOR messages for some reason. I have also tried overriding WM_DRAWITEM and WM_ERASEBGND with no success. Any ideas short of writing my own property sheet class? Thanks
Chris Hafey
|
|
|
|
|
hello,
i make a console application ,who give me the handel of one windows,and i want to use one API who use this handel given by the console application.Is that it is feasible?and how can to make it?
|
|
|
|
|
It's possible to use any Win32 API from console applications.
A. Riazi
|
|
|
|