|
Your error is telling you that that code was never compiled, did you add the header and cpp of "classref.h" to your DLL project?
|
|
|
|
|
Sure I tried the header alone and the cpp. with the header but linking message is still here.
I noticed a curious behavior as following:
1. If I put a comment on the function setval from within my Dll. Then it builds correctly
2. if I remove the comment and I just compile. This works fine as well.
3. Finally if I rebuild the DLL I get the linking errors.
|
|
|
|
|
I have got the reason of the problem.
Implementation and definition must be in the same file. I.e in the header.
But this brings to another problem that is the source code will be disclosed if the application is distributed.
|
|
|
|
|
It doesn't have to be in the same file, you just have to include both in your DLL project. As far as the source requiring to be disclosed.... well, don't pass an entire class to your DLL and you won't have to disclose the code. You should probably only pass data along. Make use of data structures instead of passing classes.
|
|
|
|
|
Presumably this is data that the dll does in fact know about.
If so the dll should provide a way to specify that data. So you use that.
If the dll doesn't provide such a way, then you must modify the dll to do that.
|
|
|
|
|
test all cases to check if can dead-lock?
But some case does not re-happen.
Is anyother quick way to do it ?
|
|
|
|
|
Ensure you have proper synchronization between threads when you need it, if it happened once and you did nothing to address the problem, odds are it'll show up again later on. Thread problems can show up differently from processor to processor, since the timing allocated to each thread can be different (on top of different speed/architecture), so make sure you synchronize properly.
I don't think there's any easy or quick way to check for race conditions.
|
|
|
|
|
Hi ,
I am working on an application which involves socket communication. Current in my read () function 'recv()' method is blocking, i.e. does not allow execution until it gets some data.
Here at this point I want to gracfully stop application . Is there any API for this ?
|
|
|
|
|
You have two obvious choices (and maybe a few more esoteric ones).
1. Google "non-blocking socket" and see how you can get to read what data is available, when you want to get it.
2. Fire up another thread which can block on the recv() call, but doesn't block your whole app. Another thread can then take control and shut down or whatever you need to do.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I remember way back when me and my buddy were at the university and had a class about networking. The class got an assignment to make a simple chat program with 2 participants using sockets. At that point we never heard of non-blocking sockets before (not sure about threads). So most people made chat programs in which the two sides could talk alternately, A sending something, then B sending, then A again, then B and so on. We on the other hand, created a "ping-pong" mechanism, a kind of "token" packet would be sent here and there between the two clients constantly, if one had something to say, it would send its content along with the token to the other client, if it had nothing to say then it would just send the token alone back. This way the clients didn't seem to block waiting for the other side to say something. Ah, the good old naive young days...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
recv() is acting on Socket S.
Keep S in a list (or some other available source).
On shutdown spin up a thread. Grab S. Close S.
Then recv() will return. Modify the code that uses that to behave correctly.
|
|
|
|
|
Thanks all. I have implemented closesocket()option successfully
|
|
|
|
|
Hi!
how i can disable font formating in CRichEditCtrl?
I want set only one default font with left alignment, like in CEdit!
From CRichEditCtrl i only need Drag & Drop features, all other must be like in CEdit!
Thanks!
|
|
|
|
|
What exactly do you mean by "disable font formatting"? You can set the default by using SetDefaultCharFormat[^] and -i guess- you "disable" any other formatting by not doing any other formatting (like, not using SetSelectionCharFormat[^]).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
key combination like "ctrl+e", "ctrl+r" make the alignment in CRichEditCtrl!
perhaps there are other hotkeys that you can use to make editing!
How i can disable it?
i found some solution:
SendMessage(EM_SETTEXTMODE, TM_PLAINTEXT, 0);
if you have any information about this, please give me link
|
|
|
|
|
No info, just what MSDN would give you, hope it works as expected.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
I am trying to debug a program that is having a problem loading bitmaps. The program compiles fine, but it crashes whenever I open a bitmap file and try to manipulate it. This is a program I inherited from someone else and it is multi-threaded and fairly large. It has been difficult to track the problem (which seems to be a runtime error), but I have done so with the usual debugging methods (breakpoints, etc) and I am lost with what to look for in the code for the problem. The program was originally built on a much older framework and this has been part of a transition from windows xp to windows 7. However, this transition has not been so easy...and I am not a professional programmer and have been learning as I encounter problems. The program always seems to crash right at this line.
CWinSTMDoc *pDoc = CreateNewDoc(GetDocument());
I step into it and get lost in a world of windows messages...
Here is the output window around where the program crashes:
WinSTM.exe': Loaded 'C:\Windows\System32\wpdshext.dll', Symbols loaded (source information stripped).
'WinSTM.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225ca\GdiPlus.dll', Symbols loaded (source information stripped).
WinSTM.exe has triggered a breakpoint
First-chance exception at 0x75c99617 (KernelBase.dll) in WinSTM.exe: Microsoft C++ exception: CInvalidArgException at memory location 0x001af0a4..
Warning: Uncaught exception in WindowProc (returning 1).
'WinSTM.exe': Unloaded 'C:\Windows\System32\wpdshext.dll'
'WinSTM.exe': Unloaded 'C:\Windows\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225ca\GdiPlus.dll'
'WinSTM.exe': Unloaded 'C:\Windows\System32\ExplorerFrame.dll'
'WinSTM.exe': Unloaded 'C:\Program Files\Common Files\microsoft shared\ink\tiptsf.dll'
The thread 'Win32 Thread' (0x884) has exited with code 0 (0x0).
Here is the code immediately before the program aborts and the debugger yells at me:
void CDocument::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU)
{
TCHAR szFullPath[_MAX_PATH];
ENSURE(lpszPathName);
if ( lstrlen(lpszPathName) >= _MAX_PATH )
{
ASSERT(FALSE);
AfxThrowFileException(CFileException::badPath);
}
if( AfxFullPath(szFullPath, lpszPathName) == FALSE )
{
ASSERT(FALSE);
AfxThrowFileException(CFileException::badPath);
}
m_strPathName = szFullPath;
ASSERT(!m_strPathName.IsEmpty());
m_bEmbedded = FALSE;
ASSERT_VALID(this);
TCHAR szTitle[_MAX_FNAME];
if (AfxGetFileTitle(szFullPath, szTitle, _MAX_FNAME) == 0)
SetTitle(szTitle);
if (bAddToMRU)
AfxGetApp()->AddToRecentFileList(m_strPathName);
ASSERT_VALID(this);
}
My gut is telling me that I have a pointer that is not returning the correct value, but I am having trouble tracking it down. Thanks for any and all help!
Best,
Andrew
|
|
|
|
|
Well, the first thing that's needed is to identify the exact error that's causing the crash.
When it crashes, look in the "Output" window, and find the exact error message wording, and show it here.
The Output window should be in the lower part of the Visual Studio main window, below where it shows the code.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Found the output window, I hope the additional information helps.
|
|
|
|
|
My hunch from the code you show, is that the error might be happening inside the "CreateNewDoc" function.
The next thing I would do is place a breakpoint at that line you said where it always crashes.
Run the program until it breaks at the breakpoint, and then single-step through the code until the error is raised. To single-step, press F11 once to enter the "CreateNewDoc" function, then F10 to execute each line of code.
Then, when the error is raised, take note of the exact line of code that you executed to cause the error, and, (very important) what function that line of code belongs to.
Now show some of the code where the error occurs.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I tried to get as close as I can to where the debugger throws an error at me.
|
|
|
|
|
I am trying to get the list of windows displayed in the windows taskbar and am doing so in the following manner:
HWND hDesktop = GetDesktopWindow();
HWND hTray = FindWindow(_T("Shell_TrayWnd"), NULL );
HWND hReBar = FindWindowEx( hTray, NULL, _T("ReBarWindow32") , NULL );
HWND hTask = FindWindowEx( hReBar, NULL, _T("MSTaskSwWClass") , NULL );
HWND hToolbar = FindWindowEx(hTask,NULL,_T("ToolbarWindow32") , _T("Running Applications") );
long cnt = SendMessage(hToolbar, TB_BUTTONCOUNT,0,0);
long pid,hprocess,text,len;
WCHAR * buttontext[128];
GetWindowThreadProcessId(hToolbar(LPDWORD)pid);
hprocess = (long)OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION,0,pid);
text = (long)VirtualAllocEx((HANDLE)hprocess,0,sizeof(buttontext),MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
for(int i=0;i<cnt;i++)
{
len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
if(len>-1)
{
ReadProcessMemory((HANDLE)hprocess, (LPCVOID)text,buttontext,sizeof(buttontext),NULL);
wcout<<buttontext<<"\n";
}
}
I have not been able to get the text and any other message eg:TB_PRESSBUTTON doesn't work either.
Any suggestions?
modified on Friday, July 29, 2011 8:38 AM
|
|
|
|
|
Please edit your question and add <pre> tags around your code to make it more readable.
The best things in life are not things.
|
|
|
|
|
Do some error checking.
It's like a Cataract Operation.
Check return values for error.
Call GetLastError to get the error value.
Use that in the error lookup tool.
All that will give you a lot of information on what is going wrong.
|
|
|
|
|
kartikdasani wrote:
len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
The value of i is counting from 0 to TB_BUTTONCOUNT . Are you sure those values match the command identifiers of the buttons on your toolbar? See here[^] for more details. You should also (always) follow Superman[^]'s advice.
The best things in life are not things.
|
|
|
|