怎样编写限制软件使用次数的程序?
例如我只要软件能使用10次就够了,请问怎么解决?谢谢!!!

解决方案 »

  1.   

    CFileStatus status;
    FILE *fp;
    CString mCishu;
    int nCount;
    char buf[512];
    if(!CFile::GetStatus("c:\\windows\\test.txt",status))
    {
    if((fp=fopen("c:\\windows\\test.txt","w"))==NULL)
    {
    AfxMessageBox("磁盘写保护,不能生成运行时所需文件。\n\n使用管理员身份运行本系统。");
    OnCancel();
    }
    mCishu="1";
    fp=fopen("c:\\windows\\test.txt","w");
    fwrite(mCishu,sizeof(char)*mCishu.GetLength(),2,fp);
    fclose(fp);
    }
      else
    {
    fp=fopen("c:\\windows\\test.txt","r");
    fread(buf,sizeof(char)*mCishu.GetLength(),2,fp);
    mCishu.Format("%s",buf);
    fclose(fp);
    nCount=atoi(mCishu);
    if(nCount<5)
    {
    nCount+=1;
    mCishu.Format("%s",nCount);
    fp=fopen("c:\\windows\\test.txt","w");
    fwrite(mCishu,sizeof(char)*mCishu.GetLength(),2,fp);
    fclose(fp);
    return;
    }
    else
    {
    AfxMessageBox("本软件超出试用次数。");
    OnCancel();
    }
    }
      

  2.   

    dim n
    if dir("c:\1")<>"" then
       open "c:\1" for input as #1
           input #1,n
       close #1
       if val(n)<=10 then
           n=val(n)+1
       else
           msgbox "已过期"
           end
       endif
       kill "c:\1"
       open "c:\1" for output as #1
           print #1,n
       close #1
    else
       open "c:\1" for output as #1
           print #1,1
       close #1
          
    endif
      

  3.   

    在目录下弄个dat\ini等等,记录已使用次数,当然要加密了,要不然人家进去改了就OK。
    还有就是EXE里直接写好在什么时间以后就过期,当然使用的人可以把系统时间调前,不过遇到数据库管理方面的那么调前了时间就不对了,这也是一个方法。