|
I explored this recently, and basically gave up (it was only a pet project, and I wanted to do .NET UI, not registry mangling and raw byte juggling.
There is no API way to enumerate Time Zone Information (neither Win32, nor .NET)
Time zone information is stored in a very strange format in the registry, under
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Time Zones\
The format is explained in a Knowledge Base article ( Q115231, search for TIME_ZONE_INFORMATION)
You basically have there:
- Name strings
- an Index (probaly for the correct sort order, since the registry has none by itself)
- a "MapID", which is probably used to shift the world map in the "select time zone dialog while windows setup
- a TZI binary structure with the actual time shift and DST switch information
(it basically indicates month, weekday and time of the switch, and which week of the month, using 5==last. very weird indeed)
You could use this information to re-build a TIME_ZONE_INFORMATION structure, then use SystemTimeToTzSpecificLocalTime (however, this works only on NT-based systems). Or you do the claculation yourself (grccch....)
Anyway, if you work your way through it, it would be nice if you can post an article I could blatantly rip off
peter
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Unfortunately, I don't believe that there are any APIs for accessing the time zone definitions stored in the registry. KB article Q221542 discusses how to decode the registry information using VB. It provides sufficient information to do it in a real language, such as C++.
Good luck on this. I've found messing around with time to be one of the most difficult programming tasks that you can attack. If you think you have it exactly right, you haven't looked at the problem hard enough.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
Hi,
I need a little function that receives the actual CPU load of the system. It should work with Win98 and WinXP (maybe two functions) but without a need to install special components (performance monitor or something). Do you know a way to do this?
|
|
|
|
|
|
Hi all,
in my W2K I right click on a file, go to properties, click on the 'Security' tab, click on 'Advanced', click on the 'Owner' tab, and I see the owner of a file.
How can I get this owner for a file in my MFC 7 application?
I'd appreciate any ideas!
Thanks a lot!
-- narada
|
|
|
|
|
Something like this:
bool GetOwner( LPCSTR lpszObjectName, CString &strOwner, CString &strDomain )
{
bool bResult = false;
PSECURITY_DESCRIPTOR pSecurityDescriptor;
PSID pSidOwner;
SID_NAME_USE rSidNameUse;
DWORD dwAccountSize,
dwDomainSize;
char *pszAccount,
*pszDomain;
strOwner = _T("<Unknown>");
strDomain = _T("<Unknown>");
if (GetNamedSecurityInfo((LPSTR) lpszObjectName, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, &pSidOwner, NULL, NULL, NULL, &pSecurityDescriptor) == ERROR_SUCCESS)
{
dwAccountSize = 0;
dwDomainSize = 0;
LookupAccountSid(NULL, pSidOwner, NULL, &dwAccountSize, NULL, &dwDomainSize, &rSidNameUse);
pszAccount = new char[dwAccountSize];
pszDomain = new char[dwDomainSize];
if (LookupAccountSid(NULL, pSidOwner, pszAccount, &dwAccountSize, pszDomain, &dwDomainSize, &rSidNameUse) == TRUE)
{
strOwner = pszAccount;
strDomain = pszDomain;
bResult = true;
}
delete [] pszAccount;
delete [] pszDomain;
LocalFree(pSecurityDescriptor);
}
return (bResult);
}
|
|
|
|
|
DavidCrow,
thanks a whole lot!
I appreciate it VERY much.
-- narada
|
|
|
|
|
Hi, everyone!
After invoking getline, I want to know what is appended at
the end of "output" in my case. It seems it is not \0. But
"strlen" function returns OK.
Output is:
--------
12
2
50
3456789
7
57
123456789
9
57
--------
Source codes:
--------
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
char input[] = "12\n3456789\n123456789";
char output[30];
istringstream is(input);
while (is.getline (output, sizeof (output), '\n'))
{
cout << output << endl;
cout << strlen (output) << endl;
if (0 == output [strlen (output) - 1])
{
cout << "Null is appended! " << endl;
}
cout << unsigned int (output [strlen (output) - 1]) << endl;
}
return 1;
}
--------
Thanks in advance,
George
|
|
|
|
|
You checked for "0" in the if-statement. Check for "\0."
if (output[strlen(output) - 1] == '\0')
{}
Kuphryn
|
|
|
|
|
Thanks, kuphryn buddie!
George
|
|
|
|
|
Hi
I have overriden OnInitialUpdate on a CFormView derived class that is implemented using DECLEARE_DYNCREATE and added to a splitter window but the overriden OnInitialUpdate never get's called.
Does anybody know why?
Thanks
Ceri
|
|
|
|
|
It's too bad to say. ^^
I created one dialog with one parent.
After creation, I tried to change my father.
Because of my application logic, it kills it's parent. .-
So, I tried like this,
SetParent(NULL) or SetParent(My friend's father)
But It does not work.
Is it impossible to change parent?
It's me, nine. nine for you.
|
|
|
|
|
Hello,
Can anybody tell me how can I get a list of the exported functions from a .lib file. The library is just a statically linked win32, compiled from Fortran I think.
I've been looking at the Lib utility, using args such as /list, but I can so far only get the list of modules within the library , not the actual function prototypes.
Thanks,
John
|
|
|
|
|
|
dumpbin /exports.
I find it very useful for Pocket PC development.
Edit: forgot that CP adds my sig by default...
--
Mike Dimmick
|
|
|
|
|
|
How to find default browser in the system (exe file)??
|
|
|
|
|
I happen to have written this a few days ago:
#include <iostream>
#include <string>
#include <windows.h>
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
static bool encuentra_programa_asociado(
std::string& programa_asociado,const char* extension)
{
char temp_path[MAX_PATH];
if(::GetTempPath(sizeof(temp_path),temp_path)==0)return false;
std::string str=temp_path;
str+="xxx.";
str+=extension;
int file=-1;
if(::_access(str.c_str(),0)!=0){
file=::_open(str.c_str(),_O_CREAT|_O_RDWR|_O_TEMPORARY,_S_IREAD|_S_IWRITE);
if(file==-1)return false;
}
char buffer[MAX_PATH];
if((DWORD)(::FindExecutable(str.c_str(),"",buffer))<=32){
if(file!=-1)::_close(file);
return false;
}
programa_asociado=buffer;
if(file!=-1)::_close(file);
return true;
}
static bool encuentra_browser_defecto(std::string& browser_defecto)
{
return encuentra_programa_asociado(browser_defecto,"htm");
}
int main()
{
std::cout<<"browser por defecto: ";
std::string str;
encuentra_browser_defecto(str);
std::cout<<str<<std::endl;
WinExec(str.c_str(),SW_SHOW);
return 0;
} It's in Spanish, but I guess you'll be able to figure it out anyway.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Does anyone know, if it's safe to append to a String in the String Table, that is used for a menu command e.g. File -> Save another string that can be used for HtmlHelp for example.
I did the following
IDS_FILE_SAVE: Save the active document.\nSave\nSave - Command\n\nSave the Document.
Then I passed it to an HH_POPUP and the Help showed up properly.
Can I continue with this, or is the space after the tooltip for the toolbar button reserved for something else?
Thanks
|
|
|
|
|
hello!
please tell me how can I see if a process(obtained with Process32First/Next) is a system process or an user process... and how can I get a full path of the exe hwo created the process...
I want to do this in Windows 95/98/Me...
thank you...
best regards,
radu.
|
|
|
|
|
I have a problem managing an ADO recorset.
I open a table and I can browse recordset data
but I'm not able to add a new record and to delete
one.
The main problem is when I open the table,
I add a new record and I try to delete this one
(without close and re-open the table) in this case
I have an exception.
In which order shall I use Open, AddNew, Update e Delete
methods in order to add and remove table records ???
Thanks a lot !!!
|
|
|
|
|
well,
if ADO uses the usaual database mechanism then open the recordset first.
Have a look if you may add and/or update records. Snapshots for instnace are not updateable.
After doing the modifications you must do an update. Maybe in the case you are doing a transaction you also have to do a commit. I don't know how ADO works, but with my database (DAO) addnew or edit just lock the record or create a new one, while update writes the record to the database. It is only after writing a record that you may delete it.
Hope this helps.
G. Steudtel
|
|
|
|
|
When you have completed the addition of a new record to your
table which is added to the end of the table and your cursor in the table is now at the end i.e EOF where there is no record that's why you find an Exception. To delete currently added record you should move the cursor one record back so that it starts point to the currently added record.
rs.MovePrev();<br />
rs.Delete();
I hope, It ll work.
Regards...
Nasir Maan
|
|
|
|
|
I am getting many errors in the following code:
#ifdef _UNICODE
typedef std::wcout _tcout;
#else
typedef std::cout _tcout;
#endif
But i am not getting any error in this code:
#ifdef _UNICODE
typedef std::wstring _tstring;
#else
typedef std::string _tstring;
#endif
Can anyone tell me what is the problem in the first case, because i am getting 8 errors. I am copying first error below:
c:\documents and settings\tstring.h(22) : error C2146: syntax error : missing ';' before identifier '_tcout'
Yes, Yes i am including all header files like iostream e.t.c
|
|
|
|
|
didn't you forget an #include <iostream> somewhere ?
~RaGE();
|
|
|
|