Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a c++ program named SBLIB DLL Ver 1.0 for Win32
I would like to convert it to 64 bit.
I tried to convert it using VS 2008, but not working.
I have the below codes, can any one help me.

I want to use this DLL in 64 bit OS. Currently this dll can work in all 32 bit OS


Source files as below:
======================

SBLIB.DEF
----------
;------------------------------------
; SBLIB.DEF module definition file
;------------------------------------

LIBRARY SBLIBVB32

DESCRIPTION 'SBLIBVB32 DLL'
;EXETYPE WINDOWS
;STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 2048
EXPORTS adths
hstad
uruu
chkday
gttime
sttime
mkttime
itvday
itvhr
itvmin
itvsec
endmon
dyweek
adtsy
sytad
todday
todhr
todmin
todsec
localttime
ad2to4
ad4to2


SBLIB.C
--------

/*
* SBLIB DLL Ver 1.0 for Win32
*
*/



#include <windows.h>
#include <stdio.h>
#include <sys\types.h>
#include <time.h>
#include <string.h>
#include "sblib.h"


int FAR PASCAL adths( int ad, int FAR *hs )
{

if( ad < 0 || ad > 99 )
return -1 ;

if( ad >=0 && ad <= 88 )
ad += 100 ;
*hs = ad - 88 ;

return 0 ;

}


int FAR PASCAL hstad( int hs, int FAR *ad )
{
if( hs <= 0 || hs > 100 )
return -1 ;

*ad = hs + 88 ;
if( *ad >= 100 ) *ad %= 100 ;

return 0 ;
}

int FAR PASCAL uruu( int year )
{
int rtn = 0;

if( year < 0 )
return -1 ;

if( ( ( year%4 == 0 ) && ( year%100 != 0 ) ) || ( year%400 == 0 ) )
rtn = 1 ;

return rtn ;
}


int FAR PASCAL chkday( TTIME FAR *ttime )
{

int year;

if( ttime->year < 0 || ttime->year > 99 )
return( -1 ) ;

if( ttime->mon < 1 || ttime->mon > 12 )
return( -2 ) ;

if( ttime->day < 1 || ttime->day > 31 )
return( -3 ) ;

year = ad2to4(ttime->year);

switch( ttime->mon ) {
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 12 :
break ;
case 4 :
case 6 :
case 9 :
case 11 :
if( ttime->day > 30 ) {
return( -3 ) ;
}
break ;
case 2 :
if( uruu( year ) == 1 ) {
if( ttime->day > 29 ) {
return( -3 ) ;
}
}
else {
if( ttime->day > 28 ) {
return( -3 ) ;
}
}
break ;

default :
return( -3 ) ;
}

if( ttime->hour < 0 || ttime->hour > 23 ) {
return( -4 ) ;
}

if( ttime->min < 0 || ttime->min > 59 ) {
return( -5 ) ;
}

if( ttime->sec < 0 || ttime->sec > 59 ) {
return( -6 ) ;
}

return( 0 ) ;
}


int FAR PASCAL gttime( TTIME FAR *ttime )
{
time_t t;
struct tm *tm;

_tzset() ;

time( &t ) ;
tm = localtime( &t ) ;

ttime->year = ad4to2(tm->tm_year);
ttime->mon = tm->tm_mon + 1 ;
ttime->day = tm->tm_mday ;
ttime->hour = tm->tm_hour ;
ttime->min = tm->tm_min ;
ttime->sec = tm->tm_sec ;

return 0 ;
}


int FAR PASCAL sttime( TTIME FAR *ttime )
{
SYSTEMTIME SystemTime;

_tzset() ;

if( chkday( ttime ) )
return( -1 ) ;


SystemTime.wYear = (WORD)ad2to4(ttime->year);
SystemTime.wMonth = (WORD)ttime->mon;
SystemTime.wDay = (WORD)ttime->day;

SystemTime.wHour = (WORD)ttime->hour;
SystemTime.wMinute = (WORD)ttime->min ;
SystemTime.wSecond = (WORD)ttime->sec ;
SystemTime.wMilliseconds = 0;

if( SetLocalTime( &SystemTime ) != TRUE )
return( -1 );

return( 0 ) ;
}


int FAR PASCAL itvday( TTIME FAR *time1, TTIME FAR *time2, long FAR *day )
{

time_t td1, td2;
double ans;


if( chkday( time1 ) )
return( -1 );

if( chkday( time2 ) )
return( -2 );

td1 = mkttime( time1 );

td2 = mkttime( time2 );

ans = difftime( td2, td1);

*day = (long) ( ans / 86400) ;

return( 0 ) ;
}

int FAR PASCAL itvhr( TTIME FAR *time1, TTIME FAR *time2, long FAR *hr )

{
time_t td1, td2;
long ans;


if( chkday( time1 ) )
return( -1 );

if( chkday( time2 ) )
return( -2 );

td1 = mkttime( time1 );

td2 = mkttime( time2 );

ans = (long)difftime( td2, td1);

*hr = (long) ( ans / 3600 );

return( 0 ) ;
}


int FAR PASCAL itvmin( TTIME FAR *time1, TTIME FAR *time2, long FAR *min )
{

time_t td1, td2;
long ans;


if( chkday( time1 ) )
return( -1 );

if( chkday( time2 ) )
return( -2 );

td1 = mkttime( time1 );

td2 = mkttime( time2 );

ans = (long)difftime( td2, td1);

*min = (long)( ans / 60 );

return( 0 ) ;
}

int FAR PASCAL itvsec( TTIME FAR *time1, TTIME FAR *time2, long FAR *sec )
{

time_t td1, td2;
long ans;


if( chkday( time1 ) )
return( -1 );

if( chkday( time2 ) )
return( -2 );

td1 = mkttime( time1 );

td2 = mkttime( time2 );

ans = (long)difftime( td2, td1);

*sec = (long)ans;

return( 0 );

}


time_t FAR PASCAL mkttime( TTIME FAR *ttime )
{
struct tm tm;
time_t mktime();


tm.tm_year = ad2to4(ttime->year) - 1900;
tm.tm_mon = ttime->mon - 1;
tm.tm_mday = ttime->day;
tm.tm_hour = ttime->hour;
tm.tm_min = ttime->min;
tm.tm_sec = ttime->sec;

tm.tm_wday = 0;
tm.tm_yday = 0;
tm.tm_isdst= -1;

return( mktime( &tm ) );

}

int FAR PASCAL endmon( TTIME FAR *ttime, int FAR *mday )
{
int year ;

if( ttime->year < 0 || ttime->year > 99 )
return( -1 ) ;

if( ttime->mon < 1 || ttime->mon > 12 )
return( -2 ) ;

year = ad2to4(ttime->year);

switch( ttime->mon )
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 12 :
*mday = 31 ;
break ;
case 4 :
case 6 :
case 9 :
case 11 :
*mday = 30 ;
break ;
case 2 :
if( uruu( year ) == 1 )
*mday = 29 ;
else
*mday = 28 ;
break ;
default :
return( -2 ) ;
}

return( 0 ) ;
}

int FAR PASCAL dyweek( TTIME FAR *ttime, int FAR *wday )
{
struct tm tm;
int rtc ;

rtc = chkday( ttime ) ;
if( ( rtc == -1 ) || ( rtc == -2 ) || ( rtc == -3 ) )
return( -1 ) ;

tm.tm_year = ad2to4(ttime->year) - 1900;
tm.tm_mon = ttime->mon - 1;
tm.tm_mday = ttime->day;
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;

tm.tm_wday = 0;
tm.tm_yday = 0;
tm.tm_isdst= -1;

mktime( &tm );

*wday = tm.tm_wday + 1;

return( 0 );

}

int FAR PASCAL adtsy( int ad, int FAR *sy )
{

if( ad < 26 || ad > 89 )
return( -1 ) ;

*sy = ad - 25 ;

return( 0 ) ;
}

int FAR PASCAL sytad( int sy, int FAR *ad )
{
if( sy < 1 || sy > 64 )
return( -1 ) ;

*ad = sy + 25 ;

return( 0 ) ;
}

int FAR PASCAL todday( TTIME FAR *time1, long day, TTIME FAR *time2 )
{
time_t t1;

if( chkday( time1 ) ) {
return( -1 );
}
t1 = mkttime( time1 );

t1 += day * 86400;

localttime( t1, time2 );

return( 0 );

}

int FAR PASCAL todhr( TTIME FAR *time1, long hr, TTIME FAR *time2 )
{
time_t t1;

if( chkday( time1 ) ) {
return( -1 );
}
t1 = mkttime( time1 );

t1 += hr * 3600;

localttime( t1, time2 );

return( 0 );

}

int FAR PASCAL todmin( TTIME FAR *time1, long min, TTIME FAR *time2 )
{
time_t t1;

if( chkday( time1 ) ) {
return( -1 );
}
t1 = mkttime( time1 );

t1 += min * 60;

localttime( t1, time2 );

return( 0 );

}

int FAR PASCAL todsec( TTIME FAR *time1, long sec, TTIME FAR *time2 )
{
time_t t1;

if( chkday( time1 ) ) {
return( -1 );
}
t1 = mkttime( time1 );

t1 += sec;

localttime( t1, time2 );

return( 0 );

}

void FAR PASCAL localttime( time_t t, TTIME FAR *ttime )
{
struct tm *tm;
time_t ts;

_tzset() ;

ts = t;
tm = localtime( &ts ) ;

ttime->year = ad4to2(tm->tm_year);
ttime->mon = tm->tm_mon + 1 ;
ttime->day = tm->tm_mday ;
ttime->hour = tm->tm_hour ;
ttime->min = tm->tm_min ;
ttime->sec = tm->tm_sec ;


}

int FAR PASCAL ad2to4( int ad2 )
{
if( ( ad2 >= 70 ) && ( ad2 <= 99 ) )
return( ad2 + 1900);
else
return( ad2 + 2000);
}

int FAR PASCAL ad4to2( int ad4 )
{
return( ad4 % 100);
}


Resource files as below
==========================
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Script1.rc
//

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Header files as below:
=====================

/*
* SBLIB HEADDER FILE
*
*
*/
#include <sys types.h="">

typedef struct {
short year;
short mon;
short day;
short hour;
short min;
short sec;
short msec;
short fu;
} TTIME;

time_t FAR PASCAL mkttime( TTIME FAR * );
int FAR PASCAL ad2to4( int );
int FAR PASCAL ad4to2( int );
void FAR PASCAL localttime( time_t, TTIME FAR *);
int FAR PASCAL dyweek( TTIME FAR *, int FAR *);

What I have tried:

I tried to load 64 bit copiler in VS2008 and tried to compile it.
It compiles with no errors, but when referred in program, it cannot be used.
Posted
Updated 21-Oct-18 4:21am
Comments
David O'Neil 20-Oct-18 2:00am    
#1: Wrap your code in 'code' tags (< code > / < /code >) without the spaces.
#2: Give the error you are receiving when trying to access the DLL using a 64 bit program.
OriginalGriff 20-Oct-18 5:43am    
<pre> tags, not <code> tags: pre tags engage the syntax highlighter.
The "code" dropdown supplies pre tags, the "variable" button gives code tags.

Don't blame me, I didn't design the site... :laugh:
David O'Neil 20-Oct-18 11:54am    
Oops! I'll try to remember that next time. I guess it makes sense, since 'pre' tags are the only ones that keep indentation correctly for code.
OriginalGriff 20-Oct-18 12:15pm    
:laugh: It's a Saturday, nobody has their brains engaged!
Richard MacCutchan 20-Oct-18 4:19am    
You need to do the same things as I suggested in your other question, and start getting familiar with the debugger. And please do not just dump a load of unformatted code in this way and expect someone else to fix it for you.

1 solution

15 seconds of Google found this: General Porting Guidelines | Microsoft Docs[^]

Which discusses issues in conversion of 32-bit Windows code to 64-bit. See also the subjects in the menu on the left of the screen.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900