|
thanks, that already helped a lot..
(the DllCpp was the problem, #define over there instead above the header..)
Since multiple header files all include this one (Engine.h),
I get several (7) Errors
Error LNK2005: "void (__cdecl* Engine::Input::on_a)(void)" (?on_a@Input@Engine@@3P6AXXZA) already defined in Engine.obj LuaScriptor.obj
But I think I can get around that problem, or just by simply putting everything inside a single header and source file.
Thanks to all for the support and the quick help
EDIT:
Fixed all (Copy everything to Engine.cpp and Engine.h), thanks
modified on Sunday, April 27, 2008 6:10 PM
|
|
|
|
|
Please,advise me that how do I get time of system in C++ language .Thanks
|
|
|
|
|
|
|
dear sir ,
i am using visual studio 2008 , and i am running the program ( that help me use the matlab in c++) but every time i try to run it appear to me this
Unhandled exception at 0x0001aa3a in teste.exe: 0xC0000005: Access violation reading location 0x0001aa3a.
and the file gs_support.c open and point on the part
#if defined (_WIN64)
cookie = systime.ft_scalar;
#else /* defined (_WIN64) */
cookie = systime.ft_struct.dwLowDateTime;
cookie ^= systime.ft_struct.dwHighDateTime;
#endif /* defined (_WIN64) */
can anyone help me , i download the program that read the function for the matlab from the codeproject from this link
link [^]
|
|
|
|
|
Greetings Programmers:
I would greatly appreciate your advice.
A few years ago, I wrote a program to automate a radio station. The program has worked well, but all the values are "hard-coded" -
every time the station changed their schedule, I had to re-code, re-compile and re-test. I am trying to develop an engine that will
read the values from a text file, giving the station personnel the ability to program the station themselves.
I am using CStdioFile to read the file. 99 times out of 100, it works perfectly - but randomly throws an exception. (The file exists,
and I don't know why it throws an exception; perhaps lack of a handle?) This is the code I use to read the file:
<CStdioFile File;
try
{
CStdioFile File(AutomationFile,CStdioFile::modeRead);
File.Seek(FilePosition,0);
int NumberOfCharactors=File.ReadString(StringRead); //StringRead is a CString
File.Close();
}
catch (CException *e)
{
TryAgain();
e->Delete();
}>
In TryAgain() I start the process over again to read the file. There is no use in creating an error message, as no one is at the station to see
it or do anything about it.
My questions:
1) Would you use another way to open and read the file?
2) How would you deal with the rare exception?
Thanks in advance for any opinions.
Gary
|
|
|
|
|
Member 3301229 wrote: I am using CStdioFile to read the file. 99 times out of 100, it works perfectly - but randomly throws an exception. (The file exists,
and I don't know why it throws an exception; perhaps lack of a handle?)
From CException::ReportError() you can know why its failed. [if you can reproduce by running it 100 times ]
Member 3301229 wrote: 1) Would you use another way to open and read the file?
You can also use C++ file streams.
Member 3301229 wrote: 2) How would you deal with the rare exception?
If the exception is so rare, it would be difficult to find and fix it. Being in maintenance project for more that one and half years, the strategy i used to use is to add extra traces and logs. So that you can catch the exception next time.
Regards,
Jijo.
________________________________
http://weseetips.com - Visual C++ technical tips.
|
|
|
|
|
Member 3301229 wrote: and I don't know why it throws an exception; perhaps lack of a handle?)
Why are you not using CFileException[^] to determine why the failure occurs. You should modify the catch block as: catch(CFileException* e)
Member 3301229 wrote: 1) Would you use another way to open and read the file?
Not really. If it failed the first time it will probably fail the second time.
Member 3301229 wrote: 2) How would you deal with the rare exception?
I would throw or log an error so I could determine the cause for failuire.[^].
One more thing... Make sure that you limit the code in your try/catch block so that it only contains code pertaining to CStdioFile operations.
Best Wishes.
-David Delaune
|
|
|
|
|
any compiler allow this?
wchar_t *p="abc";
Just mean that when compiling in unicode mode, ansi is not considered any more.
|
|
|
|
|
followait wrote: any compiler allow this?
wchar_t *p="abc";
I think any compiler allowing the above will be out of the C++ standard.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
followait wrote: Just mean that when compiling in unicode mode, ansi is not considered any more.
What do you mean by that? Is that a question?
ANSI is considered any place you use ANSI characters in a string.
There's no "Unicode mode"...the unicode preprocessor definitions are
used to conditionally compile certain APIs and structures a certain way, but
you can freely use character arrays of any type you want, anywhere you want.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
When developing a unicode application, all string should be unicode by default, so does ANSI.
I think it makes code more clear with no drawback, doesn't it?
|
|
|
|
|
Not yet, as far as I know.
Maybe a compiler switch like "treat string literals as unicode" for default string type, similar to /J option. MS compiler team may consider your request within forthcoming release.
|
|
|
|
|
e.g i have 4 states 0 0 0 0
with 2(two one's as input) as input i.e 4C2 = 6
i want to print all states
need a unique algorithm for any number
|
|
|
|
|
|
Thanq for giving this
but can u give logic with for loops in C
|
|
|
|
|
Just look at second article I gave you. In the stdcomb folder look at files IndexCombination.h and IndexCombination.cpp.
-Saurabh
|
|
|
|
|
|
Hi,
I'm trying to determine the extent of a line of text in a rich edit control via Windows API calls.
In any other control I'd use GetTextExtentPoint32(), after sending the control a WM_GETFONT message and selecting the resulting font handle into the control's device context.
The problem is that rich edit controls don't support the WM_GETFONT message, and I haven't been able to find any other way of getting a handle to the active font.
The EM_GETCHARFORMAT message provides some details about the font, but not a font handle and not enough information to create a duplicate font handle via CreateFontIndirect().
I've been banging my head on this one for about a day now, so any help would be greatly appreciated.
Thanks,
Phil
|
|
|
|
|
The problem is, in a rich edit control, the font can change on each and every character. It's also complicated by the fact that the control supports OLE embedding, which means you could have God-knows-what embedded in the text as well. I have a feeling, unless there's an explicit message provided by the control itself (I couldn't find one on MSDN), you're out of luck.
Sorry to not be of any help.
|
|
|
|
|
Thanks anyway, that's pretty much what I've concluded after trawling through MSDN and every other source I could find.
|
|
|
|
|
hi
i have this func :
void CForm1::OnCommand1()<br />
{<br />
CComVariant retval;
<br />
CString app_path;<br />
CString Icon;<br />
<br />
app_path = Str(App.path)+CString("\\")+Str(App.EXEName)+".exe";<br />
Icon = Str(App.path)+CString("\\")+"book.ico";<br />
<br />
retval = Associate_File(".abd", app_path, "abd_ext", "My own extension", Icon);<br />
AfxMessageBox(("Associated the file extension .abd with this application!"));<br />
<br />
}
and its converted from VB code by aprogram called VBto convertor.
when i compiled it , it shows an error that
error C2065: 'App' : undeclared identifier and
error C2228: left of '.path' must have class/struct/union type
as i understand .. App is aclass in VB
so my question is
Is There any equivalent class in vc++ for the App?
and if not ...
can someone please tell me what can i do about this?any help would be appreciated .
thanks in advance.
lahom
|
|
|
|
|
There is no class in VC++ for this but you can use GetModuleBaseName and GetModuleFileName to achieve same thing.
This code snippet will give you the full path to the exe i.e. app_path.
char buffer2[2048];<br />
GetModuleFileName(NULL, buffer2, 2048);
This code snippet will give you the name of the executable path.
HANDLE hProcess = GetCurrentProcess();<br />
char buffer1[2048];<br />
DWORD r1 = GetModuleBaseName(hProcess, NULL, buffer1, 2048);
So if path of running application is C:\Windows\System32\Foo.exe. GetModuleFileName will return C:\Windows\System32\Foo.exe and GetModuleBaseName will return Foo.exe. Using these two string you can easily get path of Icon which should be C:\Windows\System32.
-Saurabh
|
|
|
|
|
I don't know anything about VBto convertor. However, I'm trying to answer.
When using MFC (seeing that CString and AfxMessageBox() were used in your code snippet), there is a class named CWinApp. You can get it by calling AfxGetApp() but none of its members provides exactly what you need although it has public data members like m_pszAppName, m_pszExeName.
You can use following functions appropriately to get fully qualified executable file name and folder name.
Like;
app_path = GetExeName();
Icon = GetExeFolder() + "\\book.ico";
CString GetExeName()
{
CString str;
DWORD dwLen = GetModuleFileName(NULL,
str.GetBufferSetLength(_MAX_PATH), _MAX_PATH);
str.ReleaseBuffer(dwLen);
return str;
}
CString GetExeFolder()
{
CString str = GetExeName();
LPTSTR psz = _tcsrchr(str.GetBuffer(1), _T('\\'));
if(NULL != psz)
*psz = _T('\0');
str.ReleaseBuffer(-1);
return str;
}
|
|
|
|
|
hi
iam sorry that it took me so long to reply to ui tried using the two functions u provided me >>>> but when i check the registry ....
i found that there is no directory specified for the extension i made "for example .ccc" .i mean there is a folder for the extension but with no directory specified for the "open " command for example.
i also tried the GetModuleFileName and GetModuleBaseName
but it also the same thing ...
no directory for the icon or the commands as well.....
what shall i do now?
thank u very much for ur help all
it was very helpful.
now iam just one step away from finishing.
this is "I HOPE" the last thing to complete the creation of the associate file type
again....THANK u all
lahom
|
|
|
|