|
What date does 54294 represent, and what time does 4798 represent?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Sorry i was getting myself in a twist.
the full 4 bytes represent the date AND time which means that i need
to amalgamate the full 4 bytes into a DWORD. (which is 4 bytes or 2 words)
0xd4 <<8 + 0x16 = 54294 (date)
0x12 <<8 + 0xbe = 4798 (time)
so the datetime value is actually:
54294 << 16 + 4798.
3558211584
which i believe to be seconds since the year 1996. - However i am having trouble converting this value to an actual time now! - i am trying to get it into a SYSTEMTIME struct.
|
|
|
|
|
flippydeflippydebop wrote: which i believe to be seconds since the year 1996.
Since 1996 is not considered a special year by the computer, you'll need to add the appropriate number of seconds to that value so that it reflects date/time since, for example, 1-Jan-1970. That's roughly 820,454,400. Now you can use the date/time functions that handle values from 1-Jan-1970.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi, I am trying to write a "synchronized" function call in my dll so that programmers that use my api can expect to only make single-instance function calls. The basic motivation is that each function call spawns a thread hence I would like to greatly restrict the number of threads spawned (basically 1-and-only-1 thread spawn per function call to my api).
//In my program.h header file
int threadCode = 0; //no problem if threadCode is instantiated in the header file
HANDLE threadMutexEvent;
#define PROC_THREAD 0
#define ERR_THREAD_INUSE 1
//In my program.cpp program file
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
//problem arises if I instantiate threadCode here
//threadCode = 0;
threadMutexEvent = CreateEvent(NULL, false, true, "MutexEvent");
return true;
}
int WINAPI processRequest() {
WaitForSingleObject(threadMutexEvent, INFINITE);
if(threadCode == PROC_THREAD) {
threadCode = ERR_THREAD_INUSE;
SetEvent(threadMutexEvent);
} else {
SetEvent(threadMutexEvent);
return ERR_THREAD_INUSE;
}
//spawn thread to do some work for me
return 0;
}
As you can see, I am using Win32's synchronization mechanism to do some simple synchronization on the global variable threadCode. As seen in the code comments listed above, everything is fine if I instantiate threadCode in the header file, however, once I shift the instantiation of threadCode to DllMain the synchronization gets messed up. Basically, seperate function calls to processRequest would always "see" threadCode == PROC_THREAD and go ahead to spawn another thread (which is what I am trying to prevent
If all things fail I would fall back on leaving the instantiation in the header file, but I am really curious as to why the 2 seemingly identical instantiation calls would result in 2 drastically different results.
Thanks
|
|
|
|
|
Hi
I think the reason is that in the first case (var in header) initiation is only one time execution, but in the second case depends on dll instance.
I think your variable have to be static, try that way
Regards
David
|
|
|
|
|
Hi David,
Thanks for the reply. I have tried using static and got the same result. I am quite sure only one instance of the dll is being loaded each time my test application is using it as I have other code in DllMain that clears the UI of all user input (which I don't see happening).
Thanks
|
|
|
|
|
Another idea is replace current sync code instead a simple critical section. You have to init cs in DllMain I think that should work and is simple.
David
|
|
|
|
|
Sorry, but I think that is not a good idea put a Global var in a header file.
Put all global vars in the cpp file. In the header file only function ptototypes.
Regards
David
|
|
|
|
|
Hi David,
I took your advice and things seem fine now. No more global variables in the header file for me anymore
Thanks
|
|
|
|
|
i want that file this symbol ü to Content-Type: text/html; charset=ISO-8859-1,how read that file.
file is
FILE IS -------
D\ ü T^ V ived: by 10.82.180.5 with HTTP; Mon, 11 Dec 2006 20:39:06 -0800 (PST)
Message-ID: <c77d80a30612112039v121c49a6q2ab957200afe158a@mail.gmail.com>
Date: Mon, 11 Dec 2006 20:39:06 -0800
From: "hiimnsp uknowthatname" <uknowthatname@gmail.com>
To: uknowthatname@gmail.com
Subject: sub 15 it world
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_151408_4186001.1165898346884"
Delivered-To: uknowthatname@gmail.com
------=_Part_151408_4186001.1165898346884
Content-Type: teT^ ü d` D\ lain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
hi naveen hru .
give me some detail about it world and other thingh .
tell me some concious way .
all r right .
naveen padiyar
------=_Part_151408_4186001.1165898346884
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
hi naveen hru . give me some detail about it world and other thingh . tell me some concious way . all r righd` ü T^ br>naveen padiyar
------=_Part_151408_4186001.1165898346884--
-- modified at 6:09 Thursday 4th January, 2007
naveen padiyar
|
|
|
|
|
|
|
|
I guess maybe my database is old or bad command or...
|
|
|
|
|
hi . i want read the file ü to Content-Type: text/html; world .i find both these point starting "ü" and end"Content-Type: text/html" . that is .dbx extension file. i want to read the matter of these starting and ending point in vc++.
how i can read the text between to point starting and ending point.
naveen padiyar
|
|
|
|
|
Does any one know how to create a .dat file.
Not just saving a text file by changing the extension.
The file should only be opened using specified program and
not by other editors.
For example,Yahoo messenger archieves are stored in
.dat file format.
I want to save the data of my application in a safer way.
Help please.
Thanks
|
|
|
|
|
poda123 wrote: Does any one know how to create a .dat file.
Not just saving a text file by changing the extension.
A .dat file will have it's own file format, which won't be text. You can similarly define any file format that you like. Typically, these will contain metadata to define the values that are coming up, or will be fixed and, for example, store numbers as numbers, instead of as ASCII or Unicode values. Another option is to use compression or encryption to hide your data in your format.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
That's what really I want.
How to define my own file format.
|
|
|
|
|
At first you should think on how do you want to store that data, then serialize that data into a file using a function that encapsulates the way you want to do it. In fact, you could generate a "document" class with a load and save functions.
You can make it as complicated as you want by applying encryption methods and others, but you must decide how to do it.
In fact if you want to generate some kind of file that only your application must be able to open and understand, you should decide how do you want to store that data without thinking on making it standard in any way.
If you want to open that file automatically with your application then register the file extension.
Hope this helps.
|
|
|
|
|
There are many different ways. For instance if you want to store point coordinates you can create a structure like this
struct Point
{
double x;
double y;
};
and store all points you have consequentially in the file. There are different ways of doing that too. The simplest is using <stdio.h>
FILE* f = fopen("test.dat","bw");
fclose(f);
modified 8-Mar-17 3:51am.
|
|
|
|
|
Thanks for suggestions!
Thank you.
|
|
|
|
|
poda123 wrote: Does any one know how to create a .dat file.
In exactly the same way as you would any other file. A file's extension has no bearing on how it is created.
poda123 wrote: The file should only be opened using specified program and
not by other editors.
This is rather difficult, if at all, to achieve.
poda123 wrote: For example,Yahoo messenger archieves are stored in
.dat file format.
But that does not imply that YM could open any .dat file, only those that it created.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello Friends,
I want to change the Cursor when mouse is on Button.
This I want to do in ATL.
Abhijeet
|
|
|
|
|
You Can use SetCursor . Use CComModule::m_hInst as first parameter.
|
|
|
|
|
Alternatively, you can derive a class from CButton, implement a static method RegisterClass that will retrieve the BUTTON class info using GetClassInfo(Ex), then replace the class name with your class name, window procedure with yours and also the class hCursor with the desired cursor.
A similar technique can be found in MSDN for custom dialog classes.
|
|
|
|