1   1  /  1  页   跳转

提一个C++问题

提一个C++问题

写一个小DLL,用来设置鼠标双击的时间:
#include "stdafx.h"
#include "SetMouseInfo.h"
#include <windows.h>

BOOL APIENTRY DllMain( HANDLE hModule,
                      DWORD  ul_reason_for_call,
                      LPVOID lpReserved
                     )
{

    return TRUE;
}

BOOL SetMouseParameter()
{
    UINT iSetDblClickTime;
    UINT DblClickTime=::GetDoubleClickTime();
    if(DblClickTime!=NULL)
    {
        cout<<"当前双击时间为"<<DblClickTime<<endl;
    }
    BOOL bSet; char ysSet;
    cout<<"是否要设置双击时间,是则输入Y,否则输入N或者其它字母"<<endl;
    cin>>ysSet;
    if(ysSet=='Y' || ysSet=='y')
    {
l1:
        cout<<"请输入您要设置的时间"<<endl;
        cin>>iSetDblClickTime;
        if(iSetDblClickTime>0 )
        {
            bSet=::SetDoubleClickTime(iSetDblClickTime);
            if(bSet)
            {
                cout<<"设置成功!!"<<endl;
            }
        }
        else
        {
           
            cout<<"输入有误!!是否重新设置?(Y/N)"<<endl;
            char ysSet2;
            cin>>ysSet2;
            if(ysSet=='Y' || ysSet=='y')
            {
                goto l1;
            }
            bSet=FALSE;
        }
    }
    return bSet;
}

DEF文件:
EXPORTS
      SetMouseParameter

在主程序中调用:

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

typedef void (*PFNEXPORTFUNC)(LPCTSTR);

int main()
{
    HMODULE hModule=::LoadLibrary("SetMouseInfo.dll");
    if(hModule!=NULL)
    {
        PFNEXPORTFUNC mSetMouseInfo=(PFNEXPORTFUNC)::GetProcAddress(hModule,"SetMouseParameter");
        if(mSetMouseInfo!=NULL)
        {
            mSetMouseInfo(NULL);
        }
        ::FreeLibrary(hModule);
    }
    printf("按任意键退出");
    getchar();
    return 0;
}


可是当设置时间时,输入0正常报错,输入500正常设置.可以当输入一些奇怪的字符,如
(-100)
却进入"输入有误!!是否重新设置?(Y/N)"死循环,由不得输入Y还是N,请问这是为什么??
最后编辑2006-08-30 20:12:53
分享到:
gototop
 

高手来看啊..
gototop
 

问题找到了...
GOTO语句的判别变量应该是ysSet2而不是ysSet
.....
英语不好,干什么都吃力.
gototop
 

易语言是中文的.
可惜看过说明后,感觉是在糟粕中文.
你想想,中文+英文语法 是什么效果??
gototop
 
1   1  /  1  页   跳转
页面顶部
Powered by Discuz!NT