|
Hi all
This is my first mail to this forum.
I am seeing this message while compiling my DLL(on WIN2K), which is using SDK.
"NOTE: WINVER has been defined as 0x0500 or greater which enables
Windows NT 5.0 and Windows 98 features. When these headers were released,
Windows NT 5.0 beta 1 and Windows 98 beta 2.1 were the current versions.
For this release when WINVER is defined as 0x0500 or greater, you can only
build beta or test applications. To build a retail application,
set WINVER to 0x0400 or visit http://www.microsoft.com/msdn/sdk
to see if retail Windows NT 5.0 or Windows 98 headers are available.
See the SDK release notes for more information."
Origionaly it didn't compiled a free build but when i define this in my header file,it does compile a free build.
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
Can someone please tell how to rectify it.
Where to get these retail headers.,i am using the SDK CD which came with Oct. 2002 MSDN subscription.
Thanks in advance
Regards
Hardeep
|
|
|
|
|
It sounds like your directories are out of order: you're still including the headers which came with Visual Studio 6.0.
You should see if the SDK install put options on the Start Menu to 'Register PSDK Directories With Visual Studio', which recent versions of the SDK do. If you want a more up-to-date SDK, you can download it from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm[^].
Otherwise, ensure that the SDK directory appears before the VC98 directory in Tools > Options > Directories.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I'm writing a TCP client and server program which uses sockets, ReadFile, overlapped I/O and completion ports. To test it I've written one client and one server program which use standard winsock functions for the sake of simplicity.
When testing the server part of the program ReadFile will sometimes fail giving ERROR_IO_PENDING as the reason.
What should I do to correct this error situation? If I "leave it alone" it never wakes up again. What I've done thus far is simply close the socket and discard the session attached to it. There has to be a more intelligent way than just discovering something went wrong and killing the session.
Thanks,
Olof
|
|
|
|
|
Surely 'ERROR_IO_PENDING' just means that you will get the data in an overlapped operation later? IOW it's not an error but an intrinisic part of overlapped IO.
Sorry if I've missed the point.
Paul
|
|
|
|
|
Actually there are two parts to using ReadFile:
1. Post the ReadFile which usually returns TRUE.
2. When there is data available the completion port will be notified by the socket.
The ERROR_IO_PENDING error is uncovered when the ReadFile posting returns FALSE. If you leave it the completion port will never be notified.
Nifty, huh?
|
|
|
|
|
I have a network server framework that uses IOCP, ReadFile/WriteFile etc. So I did some experimenting.
In a simple echo server test app the WriteFile always returns no error, the data has been passed to the transport etc. It also always causes the IOCP routine to run afterwards. The ReadFile always returns 'FALSE' with a status of ERROR_IO_PENDING unless there is data ready at the time it is called. In either case the IOCP routine is entered afterwards. Both these calls are also being made from the IOCP routine.
So IME whether you see ERROR_IO_PENDING or not doesn't matter, your completion routine runs anyway.
I'm puzzled why yours appears not to.
Paul
|
|
|
|
|
Hi Paul,
Sorry I've taken so long to reply.
I think I may have found what causes the problem.
In some cases the ReadFile parameter 3 (count) added to parameter 2 (pointer) may result in an address which causes a memory protection fault. (In my case) NT4 detects this and reports an error, but in some of the cases - where there is unallocated memory available immediately after the allocated buffer - NT is "nice" and allows the ReadFile call. In other cases - where there is no memory - you get the error. This gives the error the appearance of being intermittent which caused me to start digging into the apparent fact that it always occurred after the xth call to ReadFile and what had I been doing x times elsewhere.
You get the picture.
Olof
|
|
|
|
|
Sir,
I am doing a file searching program before my appication shows its screen.
If the file exists then the main window is shown otherwise an error is reported to the client.
I know the code to be written will be in InitInstance but do not understand the exact place to write.
Say.....
if File Exists
Show the Main window
else
Do not show the main window
Report an error to the client.
Regards
Ykut
Pls guide
|
|
|
|
|
well, this seems to be pretty simple to me if i got that right:
BOOL FindFile(void)
{
BOOL bResult;
// ...
return bResult; // return TRUE if your file's been found
}
// initinstance()
if( FindFile() )
{
CYourDialog dlg;
if( dlg.DoModal() == IDOK )
// client clicked OK
else
// client clicked cancel
}
else
{
MessageBox(NULL, // your error msg...
}
//////////////////////////////////////////
i made a dialog-based app, for the sake of simplicity and clarity...
hope this helps
Я люблю русский языкь!
|
|
|
|
|
Sir,
I am doing a file searching program before my appication shows its screen.
If the file exists then the main window is shown otherwise an error is reported to the client.
I know the code to be written will be in InitInstance but do not understand the exact place to write.
Say.....
if File Exists
Show the Main window
else
Do not show the main window
Report an error to the client.
Regards
Ykut
Pls guide
I am doing a multi threaded application that involves exchange of data.
ONE UI THREAD
AND 3 WORKER THREADS.PLS LET ME HOW TO EXCHANGE THE DATA BETWEEN THESE 3 WORKER THREADS.
FOR EX:THE FIRST THREAD WILL GIVE THE SECOND THREAD THE 2 NUMBERS AS ARGUEMENTS.the second thread should return the first thread the sum.
Pls help
|
|
|
|
|
How can I integrate Perl with Microsoft Visual C++? I have both 6.0 and 7.0, but would appreciate any links or standard texts on this subject.
|
|
|
|
|
|
I use project CpolyBtn of Chris Losinger . when only one Dialog is ok.
When two Dialog then error in function OnPreSubClassWinDow, project is running but function SetFillColor is not running.
Thank
Hello
|
|
|
|
|
Try posting the question in the article forum from where you downloaded the project, Chris Losinger may reply you directly.
God is Real, unless declared Integer.
|
|
|
|
|
Hello!
To avoid flickering during scrolling and resizing I use next code:
<br />
BOOL CMyView::OnEraseBkgnd(CDC* pDC)<br />
{<br />
return TRUE;<br />
}<br />
<br />
void CMyView::OnPaint()<br />
{<br />
CPaintDC dc(this);<br />
<br />
CRect rcPaint = dc.m_ps.rcPaint;<br />
<br />
CBitmap bmp;<br />
bmp.CreateCompatibleBitmap(&dc, rcPaint.Width(), rcPaint.Height());<br />
CDC newDC;<br />
newDC.CreateCompatibleDC(&dc);<br />
CBitmap *pOld = newDC.SelectObject(&bmp);<br />
<br />
newDC.SetViewportOrg(-rcPaint.left, -rcPaint.top);<br />
<br />
OnPrepareDC(&newDC);<br />
OnDraw(&newDC);<br />
<br />
VERIFY(dc.BitBlt(rcPaint.left, rcPaint.top, rcPaint.Width(), rcPaint.Height(), &newDC, rcPaint.left, rcPaint.top, SRCCOPY));<br />
SelectObject(newDC, pOld);<br />
}<br />
But during scrolling the content is not repainted correctly. Could you help me to improve it?
Thank you in advance.
|
|
|
|
|
Reunion wrote:
newDC.SetViewportOrg(-rcPaint.left, -rcPaint.top);
try commenting this line and are you considering the scroll position ???
God is Real, unless declared Integer.
|
|
|
|
|
I want to download an encrypted exe file from server. Then a client app will unencrypt it to memory and execute it from memory. So the client can not get this important exe file. But I do not know how to do that. Can you tell me how I can realize it?
Thanks.
|
|
|
|
|
Save it to disk first, then use CreateProcess() or ShellExecute() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I need add a data file to a exe file,and also need make the additional data file changeable.Can i do that only by edit the exe file,and not need to rebuilt it from source code?
How can I do that?Or if you have any suggestion?
opening view with wild mind
|
|
|
|
|
Probably you can do it by placing data to resources, and using resource related functions. You should be able to both read and modify resources in executables without problems. I have never used this myself, though.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
I would like to use the OO approach to threads that Derel Lakin uses on his article posted on this board. It subclasses CWinThread to create a class that allows multiple instances to effectively use the same thread function, safely.
I have derived a class (CMyThread)from CWinThread following his approach. This will be my base class, with all the basic members (events) and methods to start and stop a thread, from where I derived all my other classes that need to be executed on a diffent thtead.
I have a main thread on my appliaction, CMainThread derived from CMyThread. This class will act as a socket sever, it will bind to a port waiting for incoming connections. For each new conection it will create a new object of the class CWorkerThread (also derived from CMyThread) that has the functionality needed to process my business logic transactions.It basically listens to the client socket and when it has a full command it executes the transaction bussines logic. When it finish with the transaction it goes back to listen to the client socket for more incomming commads.
For debugging purpose I limit my application to only one object of the class CWorkerThread (only on client conects to it). I have the one client sending always the same command.
The problem I see is that the transaction that I have the one client sending over and over, always same exact one, varies a lot on the time it takes to execute. Some times it gets done on 10 mili seconds (what I am expecting) and other times it may go up to a couple of minutes. I'm logging plenty of degub statements to a text file to debug the problem, all lines on the log file have a time stamp, I see that the only delays on executing the transaction are when I make ADO calls to my oracle database. I have tried the ADO calls (Select statements) using TOAD (enteprise manager) and they always take around 10 mili seconds.
The virtual function Execute() of the class CWorkerThread is the entry point of execution for the thread that I want executing the bussines logic of the transaction. From this virtual function I will access the class data members and call the class methods. Can this be a problem?
Can any one give me any ideas on what is going on? Sorry for the long message. Here are the declaration of the three clases
class CMyThread : public CWinThread
{
DECLARE_DYNCREATE(CMyThread)
protected:
CMyThread(); // protected constructor used by dynamic creation
CMyThread(AFX_THREADPROC pfnThreadProc);
// Attributes
public:
//CInternalException m_SettlementException;
protected:
CLogFile *m_pLogFile; //Pointer to the logfile object that all derived threads will use
CString m_sThreadName; //Name of the thread
CString m_sFunctionName;//Name of the function being executed
CString m_sTmp;
CString m_sErrorMessage;
//Commands that the thread responds to
HANDLE m_hEventStart;
HANDLE m_hEventStop;
//Statuses of the thread
HANDLE m_hEventWorking;
HANDLE m_hEventDone;
HANDLE m_hEventReady;
HANDLE m_hEventQuit;
//this is a pointer to an array of handles to all commands (events) that this thread supports
HANDLE m_Handles[2];
long m_nThreadTimeOut; //Number of seconds the thread waits before it times out
double m_dStartTime;
double m_dNumTransDone;
double m_dTransactionTime;
double m_dTotTime;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyThread)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
void SetThreadName(CString Value) {m_sThreadName = Value;};
void SetLogFile(CLogFile *Value) {m_pLogFile = Value;};
CLogFile *GetLogFile(void) {return m_pLogFile;};
void WriteToLog(CString Value);
void WriteToLog(int DebugLevel, CString Value);
void TerminateThread();
CString GetThreadName(){return m_sThreadName;};
//Member functions to send commands to the thread
void StartProcessing(void);
void StopProcessing(void);
//Member functions to get the status of the thread
HANDLE *GetDoneStatus(){return &m_hEventDone;};
HANDLE *GetWorkingStatus(){return &m_hEventWorking;};
HANDLE *GetReadyStatus(){return &m_hEventReady;};
HANDLE *GetQuitStatus(){return &m_hEventQuit;};
void SetThreadTimeOut(long Value) { m_nThreadTimeOut = Value;};
void RaiseInternalException(CInternalException &, CString);
// Implementation
static UINT ThreadFunc( LPVOID lpParam);
protected:
virtual ~CMyThread();
virtual UINT Execute();
void DealWithTheError();
void CatchComError(_com_error &, CString );
// Generated message map functions
//{{AFX_MSG(CMyThread)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CMainThread : public CMyThread
{
private:
//Socket stuff
WSADATA m_wsaData; SOCKET m_sServerSocket;
sockaddr_in m_saddrSocketAddres;
SOCKET m_sClientSocket;
vector<cworkerthread *=""> m_vWThreadList;
CWorkerThread *m_pWorkerThread;
HANDLE *lpQuitHandles;
int m_nMaxTransactions;
int m_nNumActiveThreads;
long m_nWaitForCommands;
long m_nWTCommandTimeOut;
long m_nSTCommandTimeOut;
long m_nServerPort;
//ADO objects for the CRS database
CString m_sCRSConnString;
CString m_sORCConnString;
CString m_sFailOverList;
public:
CMainThread();
CMainThread(AFX_THREADPROC pfnThreadProc);
virtual ~CMainThread();
long InitMainThread();
int GetNumberOfActiveThreads() {return m_nNumActiveThreads;};
void SetCRSConnString(CString Value){m_sCRSConnString = Value;};
void SetORCConnString(CString Value){m_sORCConnString = Value;};
void SetFailOverList(CString Value) {m_sFailOverList = Value;};
void SetWaitForCommands(long Value) {m_nWaitForCommands = Value;};
void SetWTTimeOut(long Value) {m_nWTCommandTimeOut = Value;};
void SetSTTimeOut(long Value) {m_nSTCommandTimeOut = Value;};
void SetServerPort(long Value) {m_nServerPort = Value;};
BOOL InitInstance();
int ExitInstance();
protected:
//It will execute all the logic of this thread
virtual UINT Execute();
private:
long CreateWorkingThread();
long CheckStopCommand();
long FatalError(CString, long);
long GetOutStoppingWorkerThreads();
long GetArrayOfStopHandles( );
};
class CWorkerThread : public CMyThread
{
private:
SOCKET m_ClientSocket;
CString m_sMessage;
char m_cMessageByte;
CString m_sFunctionName;
CString m_sORCConnString;
CString m_sFailOverList;
CADOConnect *m_pORCConn;
CADOCommand *m_pORCCommand;
CADORecordset *m_pORCRs;
_ParameterPtr m_pORCParameter;
FieldPtr m_pORCFld;
//XML document object
IXMLDOMDocument2Ptr m_objDoc;
_bstr_t m_bstrCommand, m_bstrStationNo, m_bstrStoreCode, m_bstrCheckAmt, m_bstrCheckDate, m_bstrCheckNo;
_bstr_t m_bstrClaimNo, m_bstrFM, m_bstrMR, m_bstrDL, m_bstrPhone, m_bstrZip;
public:
CWorkerThread ();
CWorkerThread (AFX_THREADPROC pfnThreadProc);
virtual ~CWorkerThread ();
BOOL InitInstance();
int ExitInstance();
void SetSocket(SOCKET Value) {m_ClientSocket = Value;};
void SetOracleConnectionString(CString Value) {m_sORCConnString = Value;};
void SetOracleFailOvers(CString Value) {m_sFailOverList = Value;};
protected:
//It will execute all the logic of this thread
virtual UINT Execute();
private:
long ParseMessage();
long InitXML();
long LoadXMLRequest();
long GetXMLValue(_bstr_t *Value, _bstr_t NodeName);
long FindSingleMatch();
long FindGroupMatch();
long InitializeADOObjects();
};
|
|
|
|
|
IIRC ADO is not thread safe. If you want to manipulate database data from threads then you need to make all database calls from the main thread of the application. This effectively serialises all database access.
From the worker thread the easiest way to do this it is to post messages to the main threads message queue.
This does have some down sides. i.e. the data has to be made thread safe, also the data needs to be available when the main thread processes the thread message.
Ant.
|
|
|
|
|
How about if each worker thread has its own database connection? Wouldn't that take care of synchronizing the database.
|
|
|
|
|
Actually, if your connection etc are all in the same thread then there should not be a problem. This would obviously mean multiple connections to the database from your application.
I still have some niggling doubt in the back of my mind for some reason but for the life of me I can't think what that is.
Ant.
|
|
|
|
|
Help!
When editing text in my treeview if I try to select part of the string with the mouse I get a "ASSERT(::IsWindow(m_hWnd))" error!
Thanks!
|
|
|
|