等待答案!
e-mail : [email protected]

解决方案 »

  1.   


    #pragma hdrstop          //如果是VC的话,去掉这三行
    #include <condefs.h>
    #pragma argsused
    #include <windows.h>
    #include <stdio.h>
    #include <windef.h>
    #include <lmcons.h>
    #include <lmshare.h>
    #include <time.h>
    #include <conio.h>
    #include <string.h>
    USERES("nowcan.res");   //如果是VC的话,去掉这一行
    //---------------------------------------------------------------------------typedef DWORD (WINAPI *SVR_NETSESSIONENUM)(const char FAR *pszServer, 
    short sLevel, char FAR *pbBuffer, 
    unsigned short cbBuffer,
     unsigned short FAR * pcEntriesRead,
      unsigned short FAR * pcTotalAvail);struct session_info_50 {
    char FAR * sesi50_cname;            //remote computer name (connection id in Netware)
    char FAR * sesi50_username;
    unsigned long sesi50_key;           // used to delete session (not used in Netware)
    unsigned short sesi50_num_conns;
    unsigned short sesi50_num_opens;    //not available in Netware
    unsigned long sesi50_time;
    unsigned long sesi50_idle_time; //not available in Netware
    unsigned char sesi50_protocol;
    unsigned char pad1;
    }; /* session_info_50 */
    struct parm
    {
    char dirt[128];
    FILE *fp;
    };
    SVR_NETSESSIONENUM pSVRNetSessionEnum;
    HANDLE ghDll_SvrApi;DWORD WINAPI thread(LPVOID lParam)
    {
    //DWORD dwWaitStatus; 
    HANDLE dwChangeHandle; 
    time_t timer;
    struct tm *tblock;
    char dir[128];
    session_info_50 *psinfo;
    WORD ent,t_ent;strcpy(dir,((struct parm *)lParam)->dirt);
    dwChangeHandle=FindFirstChangeNotification(dir,
    true,FILE_NOTIFY_CHANGE_FILE_NAME|
    FILE_NOTIFY_CHANGE_DIR_NAME|
    FILE_NOTIFY_CHANGE_ATTRIBUTES|
    FILE_NOTIFY_CHANGE_SIZE|
    FILE_NOTIFY_CHANGE_LAST_WRITE);
    if(dwChangeHandle==INVALID_HANDLE_VALUE)
    {
    printf("ERROR!!!\n");
    return(0);
    }
    printf("Watch [%s] ready.\n",dir);
    while(true)
    {
    // dwWaitStatus=
    WaitForSingleObject(dwChangeHandle,-1); 
    timer = time(NULL);
    psinfo=(struct session_info_50 *) malloc(16384);
    pSVRNetSessionEnum(NULL, 50, (char *)psinfo, 16384,&ent,&t_ent);
    tblock = localtime(&timer);
    if(psinfo->sesi50_num_conns)
    {
    printf("[%04d-%02d-%02d  %02d:%02d:%02d]: Something changed in %s by [%s]\n",
    tblock->tm_year+1900,tblock->tm_mon+1,tblock->tm_mday,
    tblock->tm_hour,tblock->tm_min,tblock->tm_sec,dir,psinfo->sesi50_cname);
    fprintf(((struct parm *)lParam)->fp,"[%04d-%02d-%02d  %02d:%02d:%02d]: Something changed in %s by [%s]\n",
    tblock->tm_year+1900,tblock->tm_mon+1,tblock->tm_mday,
    tblock->tm_hour,tblock->tm_min,tblock->tm_sec,dir,psinfo->sesi50_cname);
    }

    free(psinfo);
    FindNextChangeNotification(dwChangeHandle);
    }
    }int main()
    {
    DWORD thd;
    FILE *fp1;
    struct parm my;
    int count=0;
    ghDll_SvrApi = LoadLibrary("SVRAPI.DLL"); 
    pSVRNetSessionEnum = (SVR_NETSESSIONENUM)GetProcAddress(ghDll_SvrApi, "NetSessionEnum");printf("Share directory change notify.\n");
    printf("Copyright NowCan 2000.\n");
    if((my.fp=fopen("NetMon.log","a"))==NULL)
    {
    printf("Open LOG file ERROR!!! Program terminate.");
    return(0);
    }
    if((fp1=fopen("NetMon.ini","r"))==NULL)
    {
    printf("Init Error.\n");
    printf("Please check fwatch.ini, I give you a sample.\n");
    if((fp1=fopen("NetMon.ini","w"))!=NULL)
    {
    fprintf(fp1,"d:\\share\nc:\\windows\n");
    fclose(fp1);
    }
    else
    {
    printf("Sorry, I can't give you any sample for some reason.Maybe write protect.\n");
    }
    return(0);
    }
    printf("\n");
    while(fscanf(fp1,"%s\n",my.dirt)!=EOF)
    {
    count++;
    CreateThread(NULL,0,thread,(LPVOID *)&my,0,&thd);
    Sleep(200); 
    }
    fclose(fp1);
    if(count==0)
    {
    printf("No directory to watch!");
    return(0);
    }
    printf("\n\nPress <q> to quit.\n");
    while(getch()!='q');
    fclose(my.fp);
    FreeLibrary(ghDll_SvrApi);
    return(0);
    }
      

  2.   

    再向上提一下!随便问一下: NowCan(能量、激情、雨水、彩虹——雷雨云) 
    你用的SVRAPI.DLL是在98下的,在2000下没有!
    怎么办?
      

  3.   

    使用WNetOpenEnum()和WNetEnumResource()两个函数就可以了