如何使用C++;Win32 API? 我使用C++ Win32 API…< /P>

如何使用C++;Win32 API? 我使用C++ Win32 API…< /P>,c++,windows,winapi,C++,Windows,Winapi,我有这些价值观 pwdlastset日期(ex:25-9-2012),当前日期(ex:1-11-2012),最大PWDAGE 计算(例如54天)和14天 现在我想计算密码到期日期 我已经尝试了下面的代码 if(lastpwdchmon==currentMonth) { lCount=currentDay-lastpwdchday; }

我有这些价值观

pwdlastset日期(ex:25-9-2012),当前日期(ex:1-11-2012),最大PWDAGE 计算(例如54天)和14天

现在我想计算密码到期日期

我已经尝试了下面的代码

if(lastpwdchmon==currentMonth)
                        {
                        lCount=currentDay-lastpwdchday;
                        }
                        else if(lastpwdchmon<currentMonth)
                        {
                            lCount=((currentDay+30)-lastpwdchday);
                        }
if(lastpwdchmon==currentmount)
{
lCount=当前日期最后一个pwdchday;
}

如果(lastpwdchmon很难知道你的日期是什么,但是如果你都及时得到了,那么就把它们减去,然后把结果除以86400(60*60*24)。

DATE
是保存日期/时间的方法。它的整数部分包含一个历元的天数(这里不重要)小数部分表示一天中的时间。因此,要计算2
DATE
之间的天数,可以执行以下操作:

DATE d1 = get_date1(), d2 = get_date2();
int number_of_days = static_cast<int>( d1 - d2 );
要将日期/时间字段转换为日期,可以使用:

DATE to_date( int year, WORD month, WORD day,
    WORD h = 0, WORD m = 0, WORD s = 0, WORD ms = 0 )
{
    SYSTEMTIME stm = { year, month, 0, day, h, m, s, ms };
    DATE res;
    if( !SystemTimeToVariantTime(&stm, &res) ) {/* Handle error */}
    return res;
}

您使用的是哪种类型的日期结构?
SYSTEMTIME
DATE
FILETIME
?@BigBoss:lastpwdchday是日期…maxpwdage LONG…但我将所有日期都转换为整数。转换为刻度。添加适当的秒数。将这些刻度转换为日期…?利润!!!
get\u date1
&
get\u date2
是示例f函数,但如果您想获取当前日期,或者您有日期的各个字段,请参阅我编辑的答案
DATE to_date( int year, WORD month, WORD day,
    WORD h = 0, WORD m = 0, WORD s = 0, WORD ms = 0 )
{
    SYSTEMTIME stm = { year, month, 0, day, h, m, s, ms };
    DATE res;
    if( !SystemTimeToVariantTime(&stm, &res) ) {/* Handle error */}
    return res;
}