|
Hi
i create a console application using .Net2003.But to use it in c# i have to craete a dll file.Thats why i have to compile my program in .Net class library.But during compilation 3 errors are occur:
1.DBX error LNK2020: unresolved token (0A000018) _CxxThrowException
2.DBX error LNK2020: unresolved token (0A00001A) delete
3.DBX fatal error LNK1120: 2 unresolved externals
if i remove iostream header and namespace std and related function then it will not produce any error.
Plz send me suggestion how to resolve this problem
Parshant
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
I have created a multithreaded server application in Windows service. In the ServiceMain() function, a listening socket is created to listen for incoming client request. Upon acceptiong a new client request, a new thread will be created to handle that request. The client request is handled by the CMyThread class (parent class is CWinThread), but for debugging purpose, there is no specific implementation in the class yet. I observed that, the service application memory usage keeps on increasing against time. Each new client request will result in about 4K increase in application memory usage after the CMyThread servicing thread terminates. I am not quite sure how the AfxBeginThread() allocates memory in heap and how the CWinThread releases all used resources back to heap. During source debugging, I observed that the CMyThread object was deleted after the ExitInstance() was called.
The service application works well when no thread is created upon receiving new client request. Appreciate if someone can give me a hand on this. Thanks.
Below are snippets of the codes:
// service main function
void CMyService::ServiceMain(DWORD /*dwArgc*/, LPTSTR* /*lpszArgv*/)
{
:
:
CAsyncSocket socListen;
if (!socListen.Create(8080))
{
QuitService(strMsg);
return;
}
if (!socListen.Listen(200))
{
QuitService(strMsg);
return;
}
:
:
CSocket soc;
CMyThread* pThread;
while(!m_bStop)
{
if (socListen.Accept(soc))
{
pThread = (CMyThread*)AfxBeginThread(RUNTIME_CLASS(CMyThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
if (!pThread)
{
soc.Close();
strMsg.Format(_T("Failed to create serving thread. Error: %s."), GetLastErrorText(GetLastError()));
AfxGetService()->m_EventLogSource.Report(EVENTLOG_ERROR_TYPE, CS_MSG_SERVICE_ERROR, strMsg);
return;
}
// Pass the socket to the thread by passing the socket handle.
pThread->m_hSocket = soc.Detach();
// start the thread.
pThread->ResumeThread();
}
Sleep(1000);
}
:
:
}
// CMyThread class: MyThread.h
class CMyThread : public CWinThread
{
DECLARE_DYNCREATE(CMyThread)
protected:
CMyThread(); // protected constructor used by dynamic creation
virtual ~CMyThread();
public:
// Used to pass the socket handle from the main thread to this thread.
SOCKET m_hSocket;
// CSocket derived class that handles the connection.
CSock m_socket;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyThread)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual int Run();
//}}AFX_VIRTUAL
};
// CMyThread class: MyThread.cpp
#include "MyThread.h"
IMPLEMENT_DYNCREATE(CMyThread, CWinThread)
CMyThread::CMyThread()
{
m_bAutoDelete = TRUE;
}
CMyThread::~CMyThread()
{
}
BOOL CMyThread::InitInstance()
{
:
:
// Attach the socket handle to a CSocket object.
m_socket.Attach(m_hSocket);
m_socket.m_pThread = this;
:
:
return TRUE;
}
int CMyThread::ExitInstance()
{
m_socket.ShutDown();
m_socket.Close();
:
:
return CWinThread::ExitInstance();
}
int CMyThread::Run()
{
// TODO: Add your specialized code here and/or call the base class
PostQuitMessage(0);
return CWinThread::Run();
}
|
|
|
|
|
Well, to be honest, i didn't read your code, it's too much. But here's a general hint. It's usually better in Server-Applications that serve many Clients, especially when the maximum number if concurrent clientrequests is high or unknown, to use a thread-pool. That means, on Startup you create a certain number of threads, say 10, in suspended mode. Each time a request comes in, you check if there is a free thread, and if so let that thread handle the request. If all threads are busy, you have queue further requests. Good thing about that is, that on suddenly growing number of requests your server memory requirements don't explode. Also, you don't have the performance overhead of all the thread creation/deletion. I can't give you any more specific advise, but i hope it helps.
|
|
|
|
|
Well, to be honest, i didn't read your code, it's too much. But here's a general hint. It's usually better in Server-Applications that serve many Clients, especially when the maximum number if concurrent clientrequests is high or unknown, to use a thread-pool. That means, on Startup you create a certain number of threads, say 10, in suspended mode. Each time a request comes in, you check if there is a free thread, and if so let that thread handle the request. If all threads are busy, you have to queue further requests. Good thing about that is, that on suddenly growing number of requests your server memory requirements don't explode. Also, you don't have the performance overhead of all the thread creation/deletion. I can't give you any more specific advise, but i hope it helps.
Edit: So that's why they allways say : "Only klick that button once !" ...
|
|
|
|
|
Hi,
I need to pop a small window from below when I move my mouse to a bimap placed below the window and it should disappear once I click on the client area. Iam lack of thoughts .Any suggestions or links would be appreciated.
Thanx in Advance.
Today is a gift, that's why it is called the present
|
|
|
|
|
narayanagvs wrote: pop a small window from below
HWND hWnd=CreateWindow("STATIC","MyWindow",WS_CHILD|WS_VISIBLE|WS_BORDER|WS_POPUPWINDOW ,0,0,0,0,m_hWnd,NULL,GetModuleHandle(NULL),NULL);
for (int i=0;i<100;i++)
{
Sleep(1);
::SetWindowPos (hWnd,NULL,0,0,100,i,SWP_SHOWWINDOW);
}
// This would only be one of the options.
/// You can also try and create a pop up style Menu and use it.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Is there any way to subclass a messagebox, I want to add a hyper link in it.
|
|
|
|
|
LiYS wrote: subclass a messagebox
Hook the message box from your application
hHook = SetWindowsHookEx (WH_CALLWNDPROC,
(HOOKPROC)HookProcedure,
NULL,
GetCurrentThreadId ());
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks,But where should I put messagebox related info to SetWindowsHookEx(...)
|
|
|
|
|
LiYS wrote: But where should I put messagebox related info to SetWindowsHookEx(...)
Put them in the HookProcedure
The prototype for the HookProcedure is
LRESULT CALLBACK HookProcedure(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
You will also have to use these at appropriate places:
CallNextHookEx()
UnHookWindowsHookEx()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Filtering what inside callback?
|
|
|
|
|
LiYS wrote: Filtering what inside callback?
Use this message : WM_INITDIALOG
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I have subclass the MessgageBox but with the following winproc the Messagebox onyl display the client area, What wrong?
<br />
LRESULT CALLBACK MessageBoxProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (message)<br />
{<br />
case WM_INITDIALOG:<br />
InitLink(hWnd);<br />
return TRUE;<br />
case WM_DRAWITEM:<br />
DrawLink(hWnd, (UINT)wParam, (LPDRAWITEMSTRUCT)lParam);<br />
break;<br />
<br />
default:<br />
break;<br />
}<br />
return CallWindowProc( oldWndProc, hWnd, message, wParam, lParam );<br />
<br />
}<br />
|
|
|
|
|
See Here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Its not for hyper link but maybe it is some helpful to you here[^] and here[^]
|
|
|
|
|
Hello,
I have in the same dialog many windows "CWnd" and I use each window to show various informations. Each window is created with WS_CAPTION style to show a titel.
My problem I would like show the border from each window as active all at the same time ! I did't found any style to do that.
Thank you.
AutreChien
|
|
|
|
|
Hi
i got some problem with my code, Acctually i created two threads, a CWnd class calls the fist thread and the fist thread inreturn calls the second thread.
The second thread calls the member function of CAuthen. the second thread calls authen.CheckAuthentication(); in theat member function, i called a dialog using DoModal(); after displaying the dialog, my application gives some
Assertion Error.
can any one tell me where i did wrong.
class CAuthen:: public CWnd
{
............
..
public:
CAuthenDlg auth_dlg;
..
public :
void checkAuthentication();
};
void CAuthen :: checkAuthentication()
{
..
..
..
if( auth_dlg.DoModal() == IDOK)
{
...
// some operation goes here
}
..
..
}
Thanks in Advance.
Gopinath MV
" Don't Sit Like a Rock, Work Like a Clock "
|
|
|
|
|
gloriousgopi wrote: after displaying the dialog, my application gives some
Assertion Error.
What assertion , its showing ? where its taking you in the code?
|
|
|
|
|
|
Debug Assertion Failed!
Program : file path.
File : wincore.cpp
Line : 884
Gopinath MV
|
|
|
|
|
Its not sufficient for answer
|
|
|
|
|
You might mention that this is not with VC++ v6.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi All,
I have created custom log file and its key is added to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\CustomLog. But if I give a path value greater than say 100 characters for File key under CustomLog windows is not taking this path. Is there any restrictions on path length for File key in registry?
C++beginer
|
|
|
|
|
ashokvishnu wrote: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\CustomLog. But if I give a path value greater than say 100 characters for File key under CustomLog windows is not taking this path. Is there any restrictions on path length for File key in registry?
could i know your actual coding syntax
"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 Re
|
|
|
|
|