|
Hi Brahmma,
It was compiling and executing. But program was terminating abnormally when calling that function. Sorry for asking incomplete question.
Anurag Gandhi.
|
|
|
|
|
That's fine; did you try debugging? Where does the crash occur?
Anything I will say you will bring it down to whatever you want.
|
|
|
|
|
Anurag Gandhi wrote: SHELLEXECUTEINFO sh={0};
sh.cbSize = sizeof ( sh );
sh.fMask = SEE_MASK_INVOKEIDLIST;
sh.lpVerb = CString("properties");
sh.lpFile = strFile;
ShellExecuteEx(&sh);
Modify this to,
CString sVerb = _T("properties");
SHELLEXECUTEINFO sh={0};
sh.cbSize = sizeof ( sh );
sh.fMask = SEE_MASK_INVOKEIDLIST;
sh.lpVerb = sVerb;
sh.lpFile = strFile;
ShellExecuteEx(&sh);
Prasad
MS MVP - VC++
|
|
|
|
|
I have such a function:
template <class t=""> T& GetInst()
{
static T t;
return t;
}
I'm not sure whether this is thread safe? If T's constructor has many operations, when two thread entered this function early and later, is there such scenario: the first thread is in T's constructor's, the second thread define t again?
|
|
|
|
|
c++ itself has no concept of threads. static means one and only one, not one per thread
|
|
|
|
|
Hi,
Since the value of the locat static variable is stored on heap, per my opinion it should not be thread safe.
Manoj
Never Gives up
|
|
|
|
|
I`m REMY wrote: the second thread define t again?
I think this depends upon the Template Parameter. If first thread invokes the function with class1 type and second invokes with class2 type then those two will be entering different constructors. Since template will generate 2 copies of template class, one for class1 and other for class2.
|
|
|
|
|
|
If the function foo() have a local static variable then its not thread safe.
Manoj
Never Gives up
|
|
|
|
|
So, how to make it safe? Use thread mutex: ?
A& foo()
{
Wait_Mutex(...);
static A a;
Release_Mutex(...);
} ??
This looks very bad performance!
|
|
|
|
|
It depends on what you need. If you wish to have it shared for all threads, you need to work with it like with any other shared memory in multithreading which includes synchronisation (unless only one thread is writing the variable)
rrrado
|
|
|
|
|
Of course, I want to do a shared function by all thread. However, I hope to only have one synchronization in this function. I means, the first thread entered the synchronize, all following thread return the reference of object directly.
|
|
|
|
|
I'm trying to read a char* from a binary file. The data is written to the file correctly, but when I read it back, my string is appended with gibberish. Here's a snippit:
char* load_string(FILE* f)
{
size_t len;
char* str = NULL;
fread(&len, sizeof(size_t), 1, f);
if (len)
{
str=(char*)malloc(len);
fread(str, sizeof(char), len, f);
}
else
{
str=NULL;
}
return str;
}
And here is how I am using the function:
fopen_s(&f, "hi.dat", "rb");
if (f)
{
szLoad = load_string(f);
fclose(f);
}
I'm pretty sure it's a problem with malloc() allocating too much memory, because when I do a strlen(str) it returns as longer than expected, even though len is correctly interpreted from the file.
Any help would be greatly appreciated.
|
|
|
|
|
You need to terminate the string with a null char
malloc the length plus one byte for the '\0'
after you have read the string from the file insert a '\0' at the end of the buffer
|
|
|
|
|
dreamtwister wrote: str=(char*)malloc(len);
fread(str, sizeof(char), len, f);
You might need an extra byte for a NULL otherwise string library functions will just keep going and going and ....
led mike
|
|
|
|
|
i have used following four functions for motion detection part only:
1)AdjustMotionDetectPrecision()
2)SetupMotionDetection()
3)StartMotionDetection()
4)MotionAnalyzer()
using these four functions,motion detected has started.
but i dnt knw how to start recording????
i m sending u some code :
here it is::::
if(frameType > 0)
{
if(frameType == PktSysHeader)
{
memcpy(FileHeader[channelNum], DataBuf, Length);
FileHeaderLen = Length;
}
if(frameType == PktIFrames || frameType ==PktSubIFrames)
{
status = 1;
}
else
{
status = 0;
}
if(frameType == PktMotionDetection)
{
int result[4];
if(bOverlayMode)
{
hkdlg->m_VideoWin.DrawVectEx(channelNum, (char *)DataBuf);
}
else
{
hkdlg->m_bMoving[channelNum] = TRUE;
memcpy(motionData[channelNum],(char*)DataBuf,Length);
}
MotionAnalyzer(ChannelHandle[channelNum],(char*)DataBuf,15,result);
if((result[0] + result[1] + result[2] + result[3]))
{
if (channelNum ==0)
TRACE("!!!!!!!CH=%d motion detect result is %d %d %d %d\n",channelNum,result[0],\
result[1],result[2],result[3]);
//The function Trigger() do the following operation: write the video&audio data which are before the motion frame to file
if(!hkdlg->baftermotion[channelNum])
alarmFile[channelNum].Trigger(gFileHandle[channelNum]);
//when the motion frame returns,clear ualreadywriteframes[channelNum] and set it as 0 ,be ready for writing the video&audio data after motion
hkdlg->ualreadywriteframes[channelNum]=0;
hkdlg->baftermotion[channelNum]=TRUE;
}
return 0;
}
if(frameType == PktOrigImage)
{
return 0;
}
In this code should i start recording after motionanalyser() function?????????????
tyagi
|
|
|
|
|
i am laoding a gif image in picture box. it takes time to load the picture how to avoid this flickering ?. i cant get for gif image
-- modified at 2:00 Tuesday 22nd May, 2007
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Try SetRedraw(FALSE) before loading and SetRedraw() after the loading.
Try it with "this" and the picturebox.
You can also try to use LockWindowUpdate and UnlockWindowUpdate
I hope it helps
|
|
|
|
|
Hello,
How to import text file and covert to table(new design) in row by row and column by column based on field name.
ashost07
|
|
|
|
|
Hi,
If your text files have the TAB separeted values then opening it with the Excel will get it converted into excel sheet column wise.
Also, you can read the text fiel and use Excel APIs to get the excel sheet created. The main objects Excel.Application, Workbook etc should be used to create a excel sheet.
Manoj
Never Gives up
|
|
|
|
|
Hi,
another option is the ";" format, write the file with ".csv" and import it in Excel saying that he semicolons ";" are like TABS. We use it in that way to have in excell what we want to edit manually from IFix DB
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
this can be helpful
http://www.codeproject.com/useritems/BasicExcel.asp
|
|
|
|
|
I need a source code for a conjunctive normal form, or at least, simplify the process for me. how to transform your sentences to CNF and build a Knowledge base.
--Star
|
|
|
|
|
void main(int argc, char* argv[])
{
}
led mike
|
|
|
|
|
That's what can be given for an URGENT requirment. LOL.
Anything I will say you will bring it down to whatever you want.
|
|
|
|