GetLastError()看看。我不清楚。
SetLocalTime()设置的是本地的时间。system的那个好象设置的是国际标准时间 还要移动时区(北京 8)。
这些函数要有相应的权限。你确定是在管理员用户下编程?
反正GetLastError()就知道了。
SetLocalTime()设置的是本地的时间。system的那个好象设置的是国际标准时间 还要移动时区(北京 8)。
这些函数要有相应的权限。你确定是在管理员用户下编程?
反正GetLastError()就知道了。
i = SetLocalTime(&systime);
GetLastError();
这样还是看不到错误啊!
BOOL bOk = ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwError,
MAKEWORD(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), (LPTSTR)&hLocal, 0, NULL);
AfxMessageBox((PCTSTR)LocalLock(hLocal));
LocalFree(hLocal);
#include "得到时间.h"
#include "得到时间Dlg.h"
#include "windows.h"
#include "winbase.h"
#include "string.h"
DWORD dwError = GetLastError(); HLOCAL hLocal = NULL;
BOOL bOk = ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwError,
MAKEWORD(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), (LPTSTR)&hLocal, 0, NULL);
AfxMessageBox((PCTSTR)LocalLock(hLocal));
LocalFree(hLocal);
提示:
--------------------Configuration: 得到时间 - Win32 Debug--------------------
Compiling...
得到时间Dlg.cpp
C:\Documents and Settings\Administrator\桌面\得到时间\得到时间Dlg.cpp(234) : error C2065: 'PCTSTR' : undeclared identifier这是什么原因啊?
Res
Windows NT/2000: The SetSystemTime function enables the SE_SYSTEMTIME_NAME privilege before changing the system time. This privilege is disabled by default. For more information about security privileges, see Privileges.
就是说默认情况下你没有修改系统时间的权限,先把权限拿到手再说。我估计这样。
LocalFree(hLocal);
提示:
--------------------Configuration: 得到时间 - Win32 Debug--------------------
Compiling...
得到时间Dlg.cpp
C:\Documents and Settings\Administrator\桌面\得到时间\得到时间Dlg.cpp(234) : error C2065: 'PCTSTR' : undeclared identifier楼主,这个错误是你拼写错了,在AfxMessageBox里,少个L.
{
int i;
SYSTEMTIME systime;
systime.wYear = 2006 ;
systime.wMonth = 11;
systime.wDay = 20 ;
systime.wHour = 2;
systime.wMinute = 23;
systime.wSecond = 12;
i = SetLocalTime(&systime);
//GetLastError();
DWORD dwError = GetLastError(); HLOCAL hLocal = NULL;
BOOL bOk = ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwError,
MAKEWORD(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), (LPTSTR)&hLocal, 0, NULL);
AfxMessageBox((LPCTSTR)LocalLock(hLocal));
LocalFree(hLocal); if ( i)
{
::MessageBox(NULL,"g",TEXT("123"),MB_OK);
}
else
{
::MessageBox(NULL,"gg",TEXT("456"),MB_OK);
}}
谢谢大哥:
编译是通过了
可是没有提示什么具体的错误:
就是弹出了一个警告符号 "!"