文档库 最新最全的文档下载
当前位置:文档库 › wincc用户管理程序

wincc用户管理程序

调用用户管理的C脚本:#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
SSMProgramStart( lpszPictureName, lpszObjectName, "Passcs.exe");
}
在按钮上用ProgramExecute("Passcs.exe")脚本可以执行用户管理程序

做个登陆的画面,放2个按钮,登陆和注销,写脚本:
由函数PWRTLogin()来执行登录。
#pragma code("USEADMIN.DLL")
#include "PWRT_API.H"
#pragma code()
PWRTLogin('1');

由函数PWRTLogout()来实现注销。
#pragma code("USEADMIN.DLL")
#include "PWRT_API.H"
#pragma code()
PWRTLogout();


分别用登录按钮和注销按钮实现,在按钮的事件中输入相应的代码,

登录动作 (如事件 Mouse-click)
#pragma code (“useadmin.dll”)
#include “PWRT_api.h”
#pragma code()
PWRTLogin(’c’);


- 退出动作 (如事件Mouse-click)

#pragma code (“useadmin.dll”)
#include “PWRT_api.h”
#pragma code()
PWRTLogout();

请参考如何修改当前用户的密码
“CC_SewageDi_09_11_27_17_20_29”为自己创建的项目数据库名称;
“@CurrentUserName”用当前户名,为WinnCC自身的内部变量,文本变量16位字符集,连接一个输入输出域;
“@OldPassword”用当前用户旧密码,为需要创建的内部变量,文本变量16位字符集,连接一个输入输出域;
“@NewPassword”用当前用户新密码,为需要创建的内部变量,文本变量16位字符集,连接一个输入输出域;
“@ConfirmationPassword”用当前用户验证密码,为需要创建的内部变量,文本变量16位字符集,连接一个输入输出域;
在一个确定按钮鼠标动作中输入以下脚本
include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)
{
#pragma code("UseGen.dll")
#include "USEGENAP.H"
#pragma code()
LPCMN_ERROR err;
if(strcmp(GetTagChar("@NewPassword"), GetTagChar("@ConfirmationPassword"))==FALSE)
{
if (PWGENConnect("CC_SewageDi_09_11_27_17_20_29",err) )
{
if (PWGENChangePassword(GetTagChar("@CurrentUserName"),GetTagChar("@OldPassword"),GetTagChar("@NewPassword"),err))
{
MessageBox(NULL,"密码修改成功!","提示",MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
SetTagChar("@CurrentUserName","");
SetTagChar("@OldPassword","");
SetTagChar("@NewPassword","");
SetTagChar("@ConfirmationPassword","");
}
else
{
if ((strlen(GetTagChar("@NewPassword")) <= 5)&&(strlen(GetTagChar("@OldPassword"))!=0))
{
MessageBox(NULL,"您输入的新密码个数小于6,请重新输入!","提示",MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
SetTagChar("@NewPassword",""

);
SetTagChar("@ConfirmationPassword","");
}
else
{
MessageBox(NULL,"用户名和密码不一致,请重新输入!","提示",MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
SetTagChar("@CurrentUserName","");
SetTagChar("@OldPassword","");
}
}
}
else
{
MessageBox(NULL,"建立联接失败!","提示",MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
}
PWGENDisconnect(err);
}
else
{
MessageBox(NULL,"两次输入的新密码不一致,请重新输入!","提示",MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
SetTagChar("@NewPassword","");
SetTagChar("@ConfirmationPassword","");
}
}


相关文档