|
I am struggling with find() of map for last 15 day, my target is reading EVENTLOGRECORD from all machine at a time (with help of multithread ) and doing some processes on the information and writing to a separate file for each machine. It is working fine for a machine at a time. if I I read more than one machine for > 4 hours data from the machine, the map.find() giving exception . it is not frequently happening
What will be the error ?
My code
map<string ,cevent="" *=""> m_eventlist;
map<string,cevent *="">::iterator m_iter;
m_useriter=m_userlist.find(newkey); -
CEvent is a user defined object
thanks
|
|
|
|
|
I would guess this is because you're accessing the map (and likely other things) from multiple threads without synchronization. Multithreaded programming is hard.
Steve
|
|
|
|
|
Dear Sir,
I am using Roger Allen Preview Extension to do PrintPreview.
I have a file that I need to Preview all records and i make a loop on OnpreparePrinting to do So, I see only the last page, all previous I don't see it.
My problem perhaps is that I did n't yet use Doc/View printing, I do only printing with non Doc/View facility.
Who can help me ?
|
|
|
|
|
hi,
Here i have one probleme regarding VC++,if anyone know the solution plz give me the suggetions.the problem is that i have written a programe to diaplay the Rectangle.Now if i want to change the size of the Rectangle and move it Position of the Rectangle through mouse what i have to do?
bulusu ramanand
-- modified at 0:46 Saturday 19th August, 2006
|
|
|
|
|
|
I have 3 projects in workspace.I use VC 6.0.
project DipApi is a win32 static Library
They are all functions.
project CDib is MFC extension DLL,and use DibApi.lib
It will export a class.These is the header file Dib.h of the class,below
#include "..\DibApi\DIBAPI.H"
class AFX_EXT_CLASS CDib : public CObject
{
DECLARE_SERIAL(CDib) //serialization
......
export dll is ok.
CDibEx also is a MFC extension DLL project,use DibApi.lib too,and the upper class.
It will export a class too.These is the header file DibEx.h of the class,below
#include "..\dibapi\dibapi.h"
#include "..\cdib\Dib.h"
//This is the upper header file.I do not know whether to change it.
#define EFFECT_SCANDOWN 1
#define EFFECT_SCANUP 2
#define EFFECT_SCANRIGHT 3
class AFX_EXT_CLASS CDibEx : public CDib
{
DECLARE_SERIAL(CDibEx) //serialization
... ...
but ,when building,VC show:
Creating library Debug/CDibEx.lib and object Debug/CDibEx.exp
DibEx.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass
CDib::classCDib" (?classCDib@CDib@@2UCRuntimeClass@@A)
Debug/CDibEx.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Look for AFX_EXT_CLASS in MSDN.In Export and Import Using AFX_EXT_CLASS,it has
"For example, the DECLARE_DYNAMIC macro is defined as follows when building an extension
DLL:
#define DECLARE_DYNAMIC(class_name) \
protected: \
static CRuntimeClass* PASCAL _GetBaseClass(); \
public: \
static AFX_DATA CRuntimeClass class##class_name; \
virtual CRuntimeClass* GetRuntimeClass() const; \
The line that begins with static AFX_DATA is declaring a static object inside of your
class. To export this class correctly and access the run-time information from a client
executable, you must export this static object. Because the static object is declared with
the modifier AFX_DATA, you only need to define AFX_DATA to be __declspec(dllexport) when
building your DLL and define it as __declspec(dllimport) when building your client
executable. Because AFX_EXT_CLASS is already defined in this way, you just need to
redefine AFX_DATA to be the same as AFX_EXT_CLASS around your class definition.
For example:
#undef AFX_DATA
#define AFX_DATA AFX_EXT_CLASS
class CExampleView : public CView
{
DECLARE_DYNAMIC()
// ... class definition ...
};
#undef AFX_DATA
#define AFX_DATA
"
I am sorry for knowing unclearly,so I did know whether it relate to my problem.
Actually,I want to make two class to dlls respectively.
But I don't know where I was wrong.Please tell me ,thanks a lot!
begtostudy
|
|
|
|
|
http://msdn.microsoft.com/library/en-us/vccore/html/_core_Mutual_Imports.asp
I solved by myself!
|
|
|
|
|
Hello,
I'm don't receive any packet with winsock program.
My code is:
SOCKET RecvSocket,SendSocket;
int ReceiverAddrSize = sizeof(RecvAddr);
RecvSocket = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
SendAddr.sin_family = AF_INET;
SendAddr.sin_port = htons(Port);
SendAddr.sin_addr.s_addr = htonl(INADDR_ANY);
length = recvfrom(RecvSocket, SendBuf, BufLen, 0, (SOCKADDR *) &RecvAddr, &ReceiverAddrSize);
if (length == -1) {
printf("ERRO - RECVFROM\n");
exit(1);
}
Can you help me?
thanks
|
|
|
|
|
I have a multithreaded dll which reads and writes to files. For debugging purposes I would like to switch between multithreaded and singlethreaded from my main app. So I placed the following in the dll code
#ifdef _DLLNOUSETHREAD
LoadMonthThread();
#else
_handle = (HANDLE)_beginthreadex(NULL,0,LoadMonth,this,0,&_threadID);
if (!_handle)
ShowError();
#endif
I was hoping to simple be able to define _DLLNOUSETHREAD in the main exe to be able to switch, but it isn't working like that. The dll always fires a thread. What did I do wrong here?
|
|
|
|
|
are you rebuilding the DLL when you change the #define ?
|
|
|
|
|
What (the other) Chris is trying to say is that preprocessor directives like #ifdef modify how the code is compiled, they do not exist in the final binary (exe or dll).
So, in your example, when you compile the dll _either_ the LoadMonthThread() _or_ the _handle = ... code will be compiled into the dll, not both.
If you replace the: #ifdef, #else, #endif, with: if( SomeDllVar ) {}, else {} then your main app could change SomeDllVar.
... however, you state this is to aid in debugging, i have never seen anyone do this.
Either you need the MT, in which case suck it up (in a friendly sort of way ) and debug the MT dll, or it doesn't need to be MT.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
hello,
i want to extract message number 1800(for example) from xpsp2res.dll (c:\windows\system32\)
the problem is in findsource ;
this is my code
HANDLE handle = NULL;
HRSRC hrsrc;
HRSRC hResLoad;
DWORD dwLongBuff;
char Buffer[MAX_BUFFER_SIZE];
handle=LoadLibrary("C:\\windows\\System32\\xpsp2res.dll");
if (handle==NULL) printf("failure to load"); else printf ("loading ok\n");
hrsrc=FindResource((HMODULE)handle,MAKEINTRESOURCE(1800),RT_MESSAGETABLE);
if (hrsrc==NULL) printf("failure to load2"); else printf ("loading ok2\n");
|
|
|
|
|
I use VC++ 2005 and created a Win32 console application. I got the error messages:
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib
Error 2 fatal error LNK1120: 1 unresolved externals C:\C++ Projects\ImageStore\Debug\ImageStore.exe 1
Here is the code. Thanks in advance!
//Imagestore.cpp
#using <system.dll>
#using <system.data.dll>
using namespace System;
using namespace System::Collections::Generic;
using namespace System::Text;
using namespace System::Data;
using namespace System::Data::SqlClient;
using namespace System::IO;
namespace ImageStore
{
private ref class Class1
{
public:
static int Main(array<system::string^> ^args)
{
int errorCode = 0;
Class1 ^oMain = gcnew Class1();
System::String ^sConStr = "Data Source=YANG;Initial Catalog=NorthWind;Integrated Security = True";
int iUserID = Convert::ToInt32(args[0]);
System::String ^sRequestTime = args[1];
System::String ^sImageType = args[2];
System::String ^sFilePath = args[3];
FileInfo ^fi = gcnew FileInfo(sFilePath);
FileStream ^oImg;
BinaryReader ^oBinaryReader;
array<system::byte> ^oImgByteArray;
if (fi->Exists)
{
try
{
oImg = gcnew FileStream(sFilePath, FileMode::Open, FileAccess::Read);
oBinaryReader = gcnew BinaryReader(oImg);
oImgByteArray = oBinaryReader->ReadBytes(safe_cast<int>(oImg->Length));
oBinaryReader->Close();
oImg->Close();
oMain->SaveImage(sConStr, iUserID, sRequestTime, sImageType, oImgByteArray);
}
catch (Exception ^e)
{
Console::WriteLine(e->Message);
}
}
else
{
errorCode = 2;
}
return errorCode;
}
void SaveImage(System::String ^sConnectionString, int iUserID, System::String ^sRequestTime, System::String ^sImageType, array<system::byte> ^oImage)
{
SqlConnection ^oConn = gcnew SqlConnection();
try
{
oConn->ConnectionString = sConnectionString;
oConn->Open();
SqlCommand ^oCmd = gcnew SqlCommand("dbo.qp_SaveImage", oConn);
oCmd->CommandType = CommandType::StoredProcedure;
oCmd->Parameters->Add(gcnew SqlParameter("@iUserID", SqlDbType::Int));
oCmd->Parameters->Add(gcnew SqlParameter("@vcRequestTime", SqlDbType::VarChar, 100));
oCmd->Parameters->Add(gcnew SqlParameter("@vcImageType", SqlDbType::VarChar, 50));
oCmd->Parameters->Add(gcnew SqlParameter("@imImageFile", SqlDbType::Image, 2147483647));
oCmd->Parameters["@iUserID"]->Value = iUserID;
oCmd->Parameters["@vcRequestTime"]->Value = sRequestTime;
oCmd->Parameters["@vcImageType"]->Value = sImageType;
oCmd->Parameters["@imImageFile"]->Value = oImage;
oCmd->ExecuteNonQuery();
}
catch (Exception ^e)
{
Console::WriteLine(e->Message);
}
finally
{
if (oConn->State == ConnectionState::Open)
{
oConn->Close();
}
}
}
};
}
-- modified at 13:02 Friday 18th August, 2006
|
|
|
|
|
If this is managed code, you might try here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I got the same error, LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup, when working on a directx program using VisDev.net (2003). Your version of Visual Dev may be a little different. This worked for me, I hope it helps you.
Going into the project Properties and select the Linker folder then then select Sysem.
See SubSystem option, if it is Console, (/SUBSYSTEM:CONSOLE) try changing it to
Windows (/SUBSYSTEM:WINDOWS).
-
If this doesn’t work you should set it back. Good Luck.
People can be divided into two groups, those with something to learn and fools.
|
|
|
|
|
Hello,
I am trying to send serial port a double value as 8 sets of uint8 by means of union and receiving in the same manner.
For that, im calling read and write functions from an external '.cpp'file through class-object implementation as you see in my code.I use that implementation seperately in transmit and receive functions.
int transmit (double x)
{ union ifas
{
double d;
unsigned char u8value[8]; //uint8
};
union ifas member;
CSyncSerialComm *ObjectCSyncSerialComm; //Object in class from ext.file
ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8");
member.d = x;
printf("\nmember.d=%f\n",member.d);
ObjectCSyncSerialComm.WriteFile(m_hSerialComm, member.u8value, 8, &dwNumberOfBytesWritten, NULL);
delete ObjectCSyncSerialComm ;
return (int) member.u8value;
}
double receive(unsigned char)
{
union aachen
{ double c;
unsigned char u8value[8];
};
union aachen team;
CSyncSerialComm *ObjectCSyncSerialComm;
ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8");
ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL);
delete ObjectCSyncSerialComm ;
return (double)team.c ;
}
int main(int argc, char* argv[])
{
double var;
unsigned char z;
scanf("%lf",&var);
transmit(var);
receive(z);
return 0;
}
What i want to ask you is, in writing and reading commands i'm receiving syntax errors. If I type both in reading and writing (bold lines),
ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL);
Error==> On the left side of the structure . or .* is required
If I type as follows,
ObjectCSyncSerialComm.*ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL);
Error==> Invalid pointer used.
By the way, im using C++ Builder 6.0 Compiler.
What could be the problem? Any other problem can cause this? I could not find any solution.
Any comment and/or suggestion will be appreciated.Thank you.
Regards,
Cahit
-- modified at 12:01 Friday 18th August, 2006
|
|
|
|
|
ObjectCSyncSerialComm->ReadFile
cje
|
|
|
|
|
I am using Roger Allen Print Preview extension dll to have my print preview screen.
I don't know how to change the orientation of my preview to Landscape.
If Have many pages to show, I don't know how to pass from one page to another. When I clic on next button on the Print Preview screen It's only on the same page.
What to do? to go through pages clicking on next and previous buttons
I learn my self
-- modified at 13:12 Friday 18th August, 2006
|
|
|
|
|
I have a variable of type char*.
How can I convert it to OLECHAR* ??
|
|
|
|
|
An OLECHAR is an unsigned short .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
And how does it answer my question at all??
|
|
|
|
|
Try:
char *name = "Hello";
OLECHAR *ole = A2OLE(name);
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
THANK YOU!!!!!!!!
HAVE A WONDERFUL LIFE!
|
|
|
|
|
|
what about
OLESTR
Tanvon
Tanvon
the brain behind ...
|
|
|
|
|