|
Hi Mike
The problem is that I am trying to use code that produces accurate time stamps from an NTP server in another piece of code that transmits packets of information across the network. I need to be able to accurately time the packet transmission.
However my problem is that the NTP code that I'm using only compiles correctly when its set to Link to the static libraries whilst my transmission code is based on MFC and only compiles correctly when set to link with dynamic libraries. I know I'm not supposed to mix dynamic and static links. Is there any way around this problem? Do you know if i can link each piece of code seperately and still use the NTP code to obtain a timestamp in my transmission code or if I can change either of these pieces of code from static to dynamic or vice versa?
I hope you can help me. I've been searching the web and I'm at my wits end. I've included the errors below for both settings.
Thank you
Debs
Setting as Debug Multithreaded
MFC_socket.cpp
c:\program files\microsoft visual studio\vc98\mfc\include\afxver_.h(130) : fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
StdAfx.cpp
c:\program files\microsoft visual studio\vc98\mfc\include\afxver_.h(130) : fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
Generating Code...
Compiling...
TSCtime.c
Generating Code...
Error executing cl.exe.
Setting as Debug Multithreaded DLL
Compiling...
MFC_socket.cpp
StdAfx.cpp
Generating Code...
Compiling...
TSCtime.c
Generating Code...
Linking...
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
MFC_socket.obj : error LNK2001: unresolved external symbol "unsigned __int64 basest" (?basest@@3_KA)
MFC_socket.obj : error LNK2001: unresolved external symbol "unsigned __int64 tscfreq" (?tscfreq@@3_KA)
MFC_socket.obj : error LNK2001: unresolved external symbol "unsigned __int64 basetsc" (?basetsc@@3_KA)
MFC_socket.obj : error LNK2001: unresolved external symbol "void __cdecl recalibrate(void)" (?recalibrate@@YAXXZ)
MFC_socket.obj : error LNK2001: unresolved external symbol "unsigned __int64 recalinterval" (?recalinterval@@3_KA)
MFC_socket.obj : error LNK2001: unresolved external symbol "unsigned __int64 lastrecal" (?lastrecal@@3_KA)
Debug/MFC_socket_try1_10Nov.exe : fatal error LNK1120: 6 unresolved externals
Error executing link.exe.
|
|
|
|
|
Thought so. It appears to be an extern "C" problem. You either need to put an extern "C" block around the declarations of these variables and functions in the header (guarded with #ifdef __cplusplus ), or you should compile the NTP code as C++ (using the /TP switch to the compiler). I generally prefer the first option, because legacy code in my experience tends to use the word new somewhere along the line...
Out of interest, why does the NTP code only work when compiled with Debug Multithreaded? What errors do you get from setting Debug Multithreaded DLL?
You can get problems with heap allocations and frees if allocations happen in one module and are freed in another.
|
|
|
|
|
Thanks Mike. Second suggestion solved the immediate problem.
|
|
|
|
|
Hi all,
I am using the ssapi.dll, to work with the source safe ole automation.
My application is a visual studio add in, it checks which project is open.
I want to get the source safe connection information (ini file, user name, password) from the open project (assuming it is connected to the source safe)
can any1 show me code on how to do that???
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I am working on a project that will need some command line exe act as a important role.
But i don't like my client know those exe. Merging those tools all into a program will cost too much time. is there any tool can hide them but i can still run them from main program.
|
|
|
|
|
If you want to hide disk files programmatically, you basically have two options:
1. Use of 'ShellExec' and the 'attrib' command to set file hide/show flags
2. Use direct manipulation of the file system. I only know how to fetch file attribute flags from FILEINFO structure, but I don't know how to set them. See MSDN & The Internet for examples.
Naturally, the final option would be to take the actual .exe file and include it to your executable as a resource. Then you could execute the tool as necessary by using ShellExec and the 'res://' path identification. I am unsure of how this ultimately works, but you might wanna try it out.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
SetFileAttributes will allow you to set a file to be hidden. Of course, the user can still enable the 'Show hidden files and folders' option in Explorer.
|
|
|
|
|
You could use a quick and dirty method of naming the file something other than .EXE and then have your program rename the file before invoking it.
|
|
|
|
|
I have a class to wrap in COM dll. There is a c++ function declare
void Draw(HDC hdc, int x, int y, int w, int h)
I warp it in IDL as
HRESULT Draw([in] int** hdc, [in] int offx, [in] int offy, [in] int width, [in] int height);
STDMETHODIMP CImg::Draw(int** hdc, int offx, int offy, int width, int height)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
image->Draw((HDC)(hdc), offx, offy, width, height);
return S_OK;
}
in this way, the hdc parameter will be IntPtr in C#
so in c# code look like
IntPtr hDC = e.Graphics.GetHdc();
if (img != null)
img.Draw(hDC, 0, 0, 100, 100);
e.Graphics.ReleaseHdc(hDC);
sounds very pretty code.
but when i turn to VB6, it doesn't work.
I write the code
Private Sub Form_Paint()
Call g.Draw(hDC, 0, 0, 100, 100)
End Sub
but compiler complain it use some type that vb can't recognize
What's the better way to make this interface be used by c#, vb6, dephi smoothly?
Any idea?
|
|
|
|
|
Hi,
I have a C++ app that uses CHtmlView (MSHTML) and sets a div contentEditable="true" to enable editing.this works fine, except the Enter key isn't being processed at all. ie. Press Enter and nothing happens. If I use IHTMLDocument2::designMode then Enter works as expected. I've verified that my C++ code isn't preventing Enter from getting to MSHTML.
If I add an OnKeyUp() JS handler and process Enter there I can add <p> or <br> ok, however this breaks if you are within an Ordered/UnOrdered list as you obviously don't want to enter a <p> tag there. I guess I can write more code to hanlde this, however I'd rather just let MSHTML handle the Enter key for me.
Note that this is only an issue when I host MSHTML in my C++ app. If I use some simple html in IE with <div contentEditable="true" ..></div> then Enter works as you would expect it to.
I've searched high and low for a way to resolve this to no avail. Any suggestions much apprecited.
Neville Franks, Author of ED for Windows. Free Trial at <a href="http://www.getsoft.com">www.getsoft.com</a>
|
|
|
|
|
I have the same problem...and went through the same trial and error...
Did you ever manage to figure out what was going on?
If so would you mind sharing?
Cheers
How do I print my voice mail?
|
|
|
|
|
Hi!!!
Many of the examples of file reading using CFile uses
the char[] variable as its input buffer i.e.
<br />
char buffer[256];<br />
file.read(buffer, 256);
<br />
when i tried using a pointer to char as the buffer i get a debug assertion failure... i.e.
<br />
<br />
char* buffer = NULL;<br />
file.read(buffer, 256);<br />
<br />
what's wrong with my code? do i have to perform initialization on the char buffer?
|
|
|
|
|
You need to set char* buffer to point to some memory, not NULL.
eg.
char* buffer = new char[256]; and don't forget to:
delete buffer; when you are done.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
you need to free up some memory for the read to work
buffer = new char[ whateversizeyouwant]
then do your read
cheers
bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
I have a vector of type char and I have a current variable of type string, I am using a function to look for current in vector so:
find(vec.begin(), vec.end(), current);
It gives an error which I don't know how to fix. Please help me.
|
|
|
|
|
Snyp wrote:
I have a vector of type char and I have a current variable of type string, I am using a function to look for current in vector so:
find(vec.begin(), vec.end(), current);
It gives an error which I don't know how to fix. Please help me.
find is a member function. Is this the complete code line?
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
There is also a find in the std algorithms.
Thank You
Bo Hunter
|
|
|
|
|
can you tell me how to use find in the std algorithms because i think that this is the only find I could find
|
|
|
|
|
|
Please post the error message. You need to ensure that you've #include d <algorithm> . You either need to use name-space qualification directly:
std::find(vec.begin(), vec.end(), current); or a using declaration:
using std::find;
find(vec.begin(), vec.end(), current); or (least preferable) a using directive:
using namespace std;
find(vec.begin(), vec.end(), current); Otherwise, it's probably a type conflict, and you should post the error message.
|
|
|
|
|
I did that, It seems that it does not like looking for strings.
|
|
|
|
|
So, it compiles OK, but you're getting unexpected behaviour?
If you're using C-style strings, i.e. vec is a vector<char*> , you've probably hit the usual problem of shallow rather than deep comparison: find is comparing the pointers, rather than the strings pointed to. You could use find_if with a custom predicate (probably one that calls strcmp ), but it's probably preferable to use a vector<string> instead.
|
|
|
|
|
Hi!
I've created a class derived from a CObject class.
I use the serialisation method like it is explained in MSDN.
When I call the Serialize method of my object, I get the folling message:
"Unexpected file format."
when I trie to open a file previously saved.
Does anyone can help me?
Here my code, where m_MyObject is a MMOject object member of my document class:
<br />
void CMyAppDoc::Serialize(CArchive& ar)<br />
{<br />
CDocument::Serialize (ar);<br />
m_MyObject.Serialize (ar);<br />
}<br />
<br />
.....<br />
<br />
void MMObjects::Serialize( CArchive& archive )<br />
{<br />
CObject::Serialize (archive);<br />
<br />
if (archive.IsStoring ())<br />
{<br />
archive << m_Rect;<br />
archive << m_Type;<br />
}<br />
else}<br />
{<br />
UINT Type;<br />
archive >> m_Rect;<br />
archive >> Type;<br />
m_Type=(TYPEOBJECTS) Type;<br />
}<br />
<br />
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
Did you put the correct schema level in?
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
can any one tell me a way, how to send message from a multithreaded server to one of the connected clients.
|
|
|
|