www.digitalmars.com         C & C++   DMDScript  

c++.chat - Creating a DLL for use with WScript/VB

reply Steve Topilnycky <no.spam.steve topcatcomputing.com> writes:
I need to create a simple DLL that when called, will return the time 
offset from GMT time to my local time (Eastern Standard/Daylight Time)

The code below is basically what I need, but I do not know how to make 
it work as a DLL (I.E. return the offset).

Any suggestions?	



#include "windows.h"
#include "time.h"
#include "stdio.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 int tz;
 int sOffset;
 char msg[255];
 _tzset();

 tz=_timezone;
 if (tz == 0)
	 sOffset=0;
 else
    sOffset= (tz/60)/60;
sprintf(msg,"%d, sOffset);

MessageBox(NULL,msg,"Debug message",MB_OK);
return 0;

}

-- 

Regards,

Steve Topilnycky             
Top Cat Computing
Web:  http://www.topcatcomputing.com/
Dec 13 2002
next sibling parent reply "Walter" <walter digitalmars.com> writes:
The best suggestion I can make is pick up a copy of Jeffrey Richter's book
"Advanced Windows" which should provide all the info you need on creating
DLL's. See www.digitalmars.com/bibliography.html . Amazon lists it used for
$12.50 (a bargain!).

-Walter


"Steve Topilnycky" <no.spam.steve topcatcomputing.com> wrote in message
news:MPG.186482e3b6fc4df6989683 news.digitalmars.com...
 I need to create a simple DLL that when called, will return the time
 offset from GMT time to my local time (Eastern Standard/Daylight Time)

 The code below is basically what I need, but I do not know how to make
 it work as a DLL (I.E. return the offset).

 Any suggestions?



 #include "windows.h"
 #include "time.h"
 #include "stdio.h"

 int APIENTRY WinMain(HINSTANCE hInstance,
                      HINSTANCE hPrevInstance,
                      LPSTR     lpCmdLine,
                      int       nCmdShow)
 {
  int tz;
  int sOffset;
  char msg[255];
  _tzset();

  tz=_timezone;
  if (tz == 0)
 sOffset=0;
  else
     sOffset= (tz/60)/60;
 sprintf(msg,"%d, sOffset);

 MessageBox(NULL,msg,"Debug message",MB_OK);
 return 0;

 }

 --

 Regards,

 Steve Topilnycky
 Top Cat Computing
 Web:  http://www.topcatcomputing.com/
Dec 14 2002
parent reply Steve Topilnycky <no.spam.steve topcatcomputing.com> writes:
In the c++.chat newsgroup Walter wrote: 

 
 The best suggestion I can make is pick up a copy of Jeffrey Richter's book
 "Advanced Windows"
 
Walter, Thanks! Will do! Happy Holidays to All! -- Regards, Steve Topilnycky Top Cat Computing Web: http://www.topcatcomputing.com/
Dec 14 2002
parent "Walter" <walter digitalmars.com> writes:
Richter's book has been an invaluable resource for my own win32 programming.
Hope you find it as useful.

"Steve Topilnycky" <no.spam.steve topcatcomputing.com> wrote in message
news:MPG.1865702468d9ac49989684 news.digitalmars.com...
 In the c++.chat newsgroup Walter wrote:


 The best suggestion I can make is pick up a copy of Jeffrey Richter's
book
 "Advanced Windows"
Walter, Thanks! Will do! Happy Holidays to All! -- Regards, Steve Topilnycky Top Cat Computing Web: http://www.topcatcomputing.com/
Dec 14 2002
prev sibling parent reply "Daniel Fazekas" <fds mailbox.hu> writes:
"Steve Topilnycky" <no.spam.steve topcatcomputing.com> wrote in message
news:MPG.186482e3b6fc4df6989683 news.digitalmars.com...
 I need to create a simple DLL that when called, will return the time
 offset from GMT time to my local time (Eastern Standard/Daylight Time)
Isn't VB able to call simple Win32 API funcions? I'm sure there is a way and that would mean you have no use for a seperate DLL. Just use the GetTimeZoneInformation API: http://msdn.microsoft.com/library/en-us/sysinfo/base/gettimezoneinformation. asp I don't know what WScript stands for though. -- Daniel
Dec 15 2002
parent Steve Topilnycky <steve topcatcomputing.com> writes:
In the c++.chat newsgroup Daniel Fazekas wrote: 

 I don't know what WScript stands for though.
Windows Scripting Host
 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsconWScri
tCScriptOptions.asp  
The function is not support via VB or WScript. At least not that I could find. I use Wscript on my servers to run certain tasks. Once of which is phrasing a log that is stored in GMT time, and uploading it to a database. Since, here in the East Cost the offset differs between Daylight Savings time & Daylight Standard time, I need to create a utility DLL to calc the offset. I thus far have figured out the routine, but when it returns a negative, I get an error from Wscript. So I must have something declared wrong.. Right now, my return value is a Long INT, would a DWORD be a more appropriate declaration? Does DM support Data Base connectivity via OBDC? -- Regards, Steve Topilnycky Top Cat Computing Web: http://www.topcatcomputing.com/
Dec 23 2002