|
There is a simple (and fast) solution for this in C
#include "stdio.h"
FILE *filepointer;
char line[100];
char *kar;
fp1 = fopen("yourfilenamewithpath", "r");
kar = fgets(line, 100, filepointer); //read one line
//kar = fscanf(p, "%s", word); reads just one word until next space
//kar = getc(filepointer); reads just one character
printf("%s", line);
fclose(filepointer);
Bunburry
Education is an admirable thing but it is well to remember from time to time that nothing that is worth knowing can be taught (O.Wilde)
|
|
|
|
|
Sirs,
do you have an idea how to create a view like the output window of Visual C++ with white tabs and client area to write on?
Thank you for your kind help.
Bunburry
Education is an admirable thing but it is well to remember from time to time that nothing that is worth knowing can be taught (O.Wilde)
|
|
|
|
|
See into BCG control, you can find it into CodeProject
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Delphi can not use my lib file so how can I provide dll that I wrote in vc++ to client that works in Delphi ????
My dll exporting c style functions that use in objects of c++ {classes).
So what can I do if I want to give this dll for Delphi ???
|
|
|
|
|
non-MFC clients can only use plain C functions from DLLs. or, you could write it as a COM module. you cannot export C++ functions to non-C++ clients.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Maybe these will help: (?)
http://www.drbob42.com/delphi/headconv.htm
http://www.mindspring.com/~cityzoo/tips/loadlib.txt
|
|
|
|
|
|
Hello,
I am trying to implement a multimedia timer in my app.. So far I think most of what I have done is correct but I am having a few problems.. I have been refrencing http://www.codeproject.com/system/timers_intro.asp#MMTimers and it has helped out quite a bit.. Here is what I have implemented so far..
OnStart()
{
.
.
.
TIMECAPS tc;
timeGetDevCaps(&tc, sizeof(TIMECAPS));
DWORD resolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
timeBeginPeriod(resolution);
timeSetEvent(iS,resolution,TimerFunction,(DWORD)this,TIME_PERIODIC);
void CTimerDlg::MMTimerHandler(UINT nIDEvent)
{
iS --;
m_timer2.Display(iS,iM,iH,iD,(CString)m_strTimer2="%D:%H:%M:%S");
}
void CALLBACK TimerFunction(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
CTimerDlg* obj = (CTimerDlg*) dwUser;
obj->MMTimerHandler(wTimerID);
}
When compiling I get a error that states "'timeSetEvent' : cannot convert parameter 3 from 'void (unsigned int,unsigned int,unsigned long,unsigned long,unsigned long)' to 'void (__stdcall *)(unsigned i
nt,unsigned int,unsigned long,unsigned long,unsigned long)'"
Anyone know what the problem may be?
Thanks again for helping out!
Rob
|
|
|
|
|
|
I just thought this code is correct, but my app crashes. Here it is:
void Log()
{
FILE *log;
if((log = fopen("C:\\foo.log","a+t")) == NULL)
return;
SYSTEMTIME systime;
GetSystemTime(&systime);
char text[128];
sprintf(text,"%s.%s.%s\t%s:%s",systime.wDay,systime.wMonth,systime.wYear,systime.wHour,systime.wMinute);
size_t len = strlen(text);
fwrite(text,sizeof(char),len,log);
fclose(log);
}
any help is apreciated
|
|
|
|
|
what is 'len' ? (0? 10,1000,000 ?)
any chance you've overrun the 128 characters? (use snprintf to be safe).
also, why not just use fprintf, instead or using a temp buffer ?
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Oops - the SYSTEMTIME members are WORDs, not char*...
|
|
|
|
|
Alternative that I use --
void LogAuditMessage(DWORD nThreadID, LPCSTR szfmt, ...)
{
va_list args;
va_start(args, szfmt);
static bool bCheckDone(false);
if (!bCheckDone)
{
SYSTEMTIME Current;
GetLocalTime(&Current);
strcpy(m_cDateFormat, "");
sprintf(m_cDateFormat, "%04d%02d%02d", Current.wYear, Current.wMonth, Current.wDay);
if (!FileExists(".\\Audit\\."))
_mkdir(".\\Audit");
bCheckDone = true;
}
char sBuff[100] = "";
sprintf(sBuff, ".\\Audit\\%s.log", m_cDateFormat);
FILE* f;
char szBuf[1024];
char cTimeBuff[50] = "";
_strtime(cTimeBuff);
_vsnprintf(szBuf, 1024, szfmt , args);
va_end(args);
f = _tfopen(_T(sBuff), _T("a"));
if (f != NULL)
{
_ftprintf(f, _T("%08x, %s, %s\n"), nThreadID, cTimeBuff, szBuf);
fclose(f);
}
}
|
|
|
|
|
I am using CWinThread to process data. The processing is working great, but the graphs that I am loading don't display fast enough to keep up with the data processing. How can I get my thread to wait for the graphics to finish displaying??? right now I am using Sleep statements, but I know that this is not a good idea. Any advice is appreciated.
Thanks.
|
|
|
|
|
You can use the standard synch objects, probably an event would be the best for your situation. Look up CreateEvent() in MSDN, and go from there.
--Mike--
http://home.inreach.com/mdunn/
your with and
|
|
|
|
|
Thanks for your reply... I have been messing around trying to get this to work with a CreateEvent, but I can't get it. Do you happen to have some example code, or know where I can find an example of this working. Thanks in advance.
|
|
|
|
|
|
[client]->[com]->[DLL] function calls
[DLL]->[com] window message
[com]->[client] function retvals and events
I have a com object where i use loadlibrary,
i want to recive windows message to the com from the dll
is that possible?
Christer
|
|
|
|
|
I am wondering if anyone has installed STLPort-4.5 on their VC++ installation?
I have downloaded it (after being introduced to it by Christian Graus) and read through the doco. If I want to use the iostream that comes with STLPort-4.5 I use installation method 1. If I don't want the iostream then I use method 2.
I am wondering what I lose/gain by using the STLPort-4.5 versions?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
>I am wondering what I lose/gain by using the STLPort-4.5 versions?
Are you talking in general or specific to the 4.5 version ?
I have been told by a friend who had installed it, that it is general a better version of STL implementation, and that it had a few extra's like hash_map and so on. As I recall I have also browsed the code and I remember thinking it was much more readable than the crap the comes with VC.
|
|
|
|
|
I think I am talking about the iostream stuff that comes with 4.5. Also if I will break anything else in VC++ if I install it.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
Yes, it does better with compliance, although definitely not perfect. (Use C++ Builder or CodeWarrior for that. I don't even recommend GCC for compliance -- it fails for me on bitset operations.)
From what's been posted on the site, I hear the Dinkumware upgrade is better with VC, but I can't attest to this -- I got BCB for less than Dinkumware's STL upgrade.
CodeGuy
The WTL newsgroup: 940 members and growing ... http://groups.yahoo.com/group/wtl
|
|
|
|
|
When I was debugging a multi-threaded program, it generated a unhandled exception and I got the following call stack:
NTDLL! 77fcbaac()
KERNEL32! 77e665d6()
CNoTrackObject::operator new(unsigned int 4) line 84 + 12 bytes
CThreadLocal<_AFX_CTL3D_THREAD>::CreateObject() line 190 + 34 bytes
CThreadLocalObject::GetData(CNoTrackObject * (void)* 0x5f496dc0 CThreadLocal<_AFX_CTL3D_THREAD>::CreateObject(void)) line 404 + 3 bytes
CThreadLocal<_AFX_CTL3D_THREAD>::GetData() line 173 + 13 bytes
CThreadLocal<_AFX_CTL3D_THREAD>::operator _AFX_CTL3D_THREAD *() line 183 + 15 bytes
AfxInitThread() line 272 + 10 bytes
_AfxThreadEntry(void * 0x0235fc78) line 73
_threadstartex(void * 0x1ab86af8) line 212 + 13 bytes
KERNEL32! 77e6758a()
Could anyone tell me why it got into those functions?
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Hi.
I was wondering if there are any sites or resources that talk about multiprocessor programming or has code snippets etc for this. With this, you should be able to get very close to semi hard realtime I am assuming. Does anyone also have any ideas of where to find any clues about writing somesort of driver or something that can constantly do lets say data acquisition and such at a hard realtime rate while the GUI works when it can?
Thanks
|
|
|
|
|
Here is a function:
void Foo(CFtpConnection *pFtpConnection)
{
CFtpFileFind finder(pFtpConnection);
CString currentDir;
BOOL bFlag=FALSE;
bFlag=finder.FindFile(NULL);
pFtpConnection->GetCurrentDirectory(currentDir);
while(bFlag) {
bFlag=finder.FindNextFile();
if(!finder.IsDots()) {
pFtpConnection->SetCurrentDirectory(finder.GetFileName());
pFtpConnection->SetCurrentDirectory(currentDir);
}
}
finder.Close();
}
When I call this function with a valid CFtpConnection object's address, will it generate some errors? If so, could you explain something to me?
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|