|
i want to use in my code CTime!!!
any one can help
|
|
|
|
|
how about
1) try some patience & manners
2) use :-
#include <ctime>
[edit] this is asuming you dont mean the MFC CTime class - if you mean that you'll have to add the MFC includes etc if you havnt build an MFC project [/edit]
'g'
|
|
|
|
|
|
#include <atltime.h>
COleDateTime has a better range
#include <ATLComTime.h>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i'm using window forms application and i'm facing a problem with a variable date_time that hold
a long value 1243930978
I need to convert this number to datetime
Note : when i declare the variable as "CTime sss" it give error undeclared identifier "sss"
any one can help?
|
|
|
|
|
|
Hi,
this forum is about C++/CLI, that's the managed C++ dialect, part of .NET
it has a very nice DateTime class with some constructors, and useful methods such as Parse() and TryParse().
AFAIK there is no CTime in its universe.
Are you in the right forum? for plain C/C++ and MFC use the appropriate forum!
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
The value, 1243930978, is calculated from the number of seconds from 1/1/1970. To convert to a DateTime , you must account for this offset:
DateTime time_offset(1970, 1, 1);
DateTime time_converted = time_offset.AddSeconds(1243930978);
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Wednesday, June 3, 2009 4:36 PM
|
|
|
|
|
Thank you very much, i want you to know that i spend 2 days on this.
and now you gave me the right answer Thankkkkkkkkk youuuuuuuuuuuuuuuuuu.
i tried it works it gave me 3 hours difference and i handle it by adding 10800 sec
to the number. but why it gave me difference 3 hours?
|
|
|
|
|
If the value was created on computer in local time EST, and it was converted on a computer in local time PST, you will have a 3 hour difference. You should use coordinated universal time (UTC) and adjust the time according to the local time of the computer. .NET has DateTime.UtcNow and DateTime.ToUniversalTime and C/C++ has gmtime .
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Thursday, June 4, 2009 8:02 AM
|
|
|
|
|
Please can you give me exactly how to use this function in the code?
|
|
|
|
|
|
Thanks it works fine. with UtcNow
|
|
|
|
|
Hello,
I am experiencing some link errors and would like to ask your help please.
I have a managed C++ workspace, which contains the main app (.exe) and a DLL project that it links to called Editor.dll.
The DLL contains MFC classes for the doc/view classes (e.g. CEditorDoc, CEditorView, etc).
The DLL builds fine, but the main application .exe (managed C++) produces link errors when these DLL classes are used
within it, as demonstrated below:
Linking...
WindowsApplication.obj : error LNK2028: unresolved token "public: static struct CRuntimeClass
* __stdcall CEditorDoc::GetThisClass(void)" (?GetThisClass@CEditorDoc@@$$FSGPAUCRuntimeClass@@XZ) referenced
in function "int __thiscall CWindowsApplication::InitInstance(void)"
(Please note the header files are included in the main app file where they are used too).
The link errors all seem to be related to a "GetThisClass()" function which i think seems to have trouble being
exported out of the DLL (it is a member of base class MFC). All other functions seem fine. I also have tried
using a .def file but it doesnt seem to help.
Any help would be greatly appreciated. Thanks!
modified on Wednesday, June 3, 2009 8:34 AM
|
|
|
|
|
James1976 wrote: a DLL project that it links to called Editor.dll.
Links to how? Did you link to the impost library (Editor.lib)?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your reply.
I couldnt link the .lib (Editor.lib) as the .lib file is only generated if the DLL contains any exports, which it doesnt currently.
I cant export the function that has the link error (the GetThisClass() function) as its not in my code. Its in the MFC base-class and i cant override it in order to place a "declspec(export)" in front of it.
Also i cant export the entire class since it contains managed C++ code and so cannot be exported (only a class that does not contain managed code can be exported it seems).
Any further suggestions would be appreciated? Thanks.
|
|
|
|
|
James1976 wrote: I couldnt link the .lib (Editor.lib) as the .lib file is only generated if the DLL contains any exports, which it doesnt currently.
Then you have nothing to link to.
James1976 wrote: I cant export the function that has the link error (the GetThisClass() function) as its not in my code. Its in the MFC base-class and i cant override it in order to place a "declspec(export)" in front of it.
Then you create your own function that you can export and it calls the MFC function.
James1976 wrote: (only a class that does not contain managed code can be exported it seems).
That is not true. We use a DLL that I authored that is a mixed mode DLL that exports a native C++ class. That class is used in a native Win32 application. The native classes you export cannot use any managed types as parameters because then they would not be a native interface. However they can use managed objects in the implementation.
James1976 wrote: Any further suggestions would be appreciated?
See here[^]
|
|
|
|
|
Gracias!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Tomorrows is FRIDAY!
|
|
|
|
|
Hi Mike, thanks for your reply.
led mike wrote: Then you create your own function that you can export and it calls the MFC function.
Even if i add my own function there will still be a compilation error due to the base-class function. I dont think this will work as the base-class function is still directly called by base-class code (that is, the GetThisClass() function is called by the IMPLEMENT_DYNAMIC macro in MFC). I cannot modify MFC to call my own newly added function.
led mike wrote: That is not true. We use a DLL that I authored that is a mixed mode DLL that exports a native C++ class. That class is used in a native Win32 application. The native classes you export cannot use any managed types as parameters because then they would not be a native interface. However they can use managed objects in the implementation
When i tried to place the "declspec(export)" declaration in front of any class that contains managed C++, it generated a compiler error. I wonder why it worked okay for you, perhaps i dont have something correct in my code? I'll double-check this, thanks.
led mike wrote: See here[^]
Thanks for your link. I have already tried most of these, including using a .def file (which seemed to accept the .def file but still displayed the linkage errors) and using the declspec(export) for the class as mentioned above.
I have a small sample project that i could email to demonstrate, if yourself or anyone else wouldnt mind taking a look? Any help would be greatly appreciated.
Thanks,
James
|
|
|
|
|
James1976 wrote: Thanks for your link. I have already tried most of these
Have you seen this[^]?
|
|
|
|
|
led mike wrote: Have you seen this[^]?
Thanks Mike i will give that a read and make sure that i have set up my DLL correctly. Perhaps there's something i have done.
Thanks again,
James
|
|
|
|
|
I have suucesfully created Manifext.xml.
DRMInitEnvironment function fails giving me the error code 0x8004cf19 i.e. E_DRM_BROKEN_CERT_CHAIN.
Following is error trace
Running sample OfflinePublishing...
The machine is already activated.
The user is already activated.
A client licensor certificate is already i
DRMInitEnvironment failed. hr = 0x8004cf19
|
|
|
|
|
Hello,
I would like to return a multidimensional array from a pointer function.But multidimensional array dimension's will be enormous.For example,width will be 500 and height will be 600.
Could you help me please?
|
|
|
|
|
Hello,
I wrote following code to return multidimensional array from pointer function.Input parameter of this function is one dimensional array, output is pointer that point multidimensional array.
double **function( array< double>^ data,int width,int height )
{int i;
double **R;
R=new double *[height];
for (i=0;i<height;i++)
{
R[i]=new double [width];
}
return R;
}
int main( void ) {
int M=2;
int N=10;
int i,j;
array< array< double >^ >^ input = gcnew array< array< double >^ >(M);
for (j=0;j<input->Length;j++){
input[j]=gcnew array<double>(N);}
double **result1;
result1 = new double *[N];
for(i=0;i<N;i++)
{result1[i]=new double [M];}
double **result2;
result2 = new double *[N];
for(i=0;i<N;i++)
{result2[i]=new double [M];}
result1=function(input[0],M,N)
result2=function(input[1],M,N)
for (i=0;i<N;i++)
{delete R[k];}
delete R;}
return 0;
}
I built this program succesfully in Visual Studio 2008.When I debug this code,the program computed result1 but during computing result2 in the function here:
R=new double *[height];
for (i=0;i<height;i++)
{
R[i]=new double [width];
}
Visual Studio give this error:
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in stdeneme.exe Additional information: External component has thrown an exception.
Unfortunately I can't understand this error. How can I overcome of this problem?Could you help me please?
Best Regards..
|
|
|
|