FILE *fp; 

NPError NPP_NewStream(NPP instance,

                         NPMIMEType type,

                         NPStream* stream,

                         NPBool seekable,

                         uint16* stype)

{

     MessageBox(NULL, "NPP_NewStream", "INFO", MB_OK);

       fp = fopen("C:\\FILE.BIN", "wb"); // 必须为 b 模式,否则 fwrite 写入数据不正确

     if(instance == NULL)

{

         return NPERR_INVALID_INSTANCE_ERROR;

}

     NPError rv = NPERR_NO_ERROR;

     return rv;

}

 

int32 NPP_WriteReady (NPP instance, NPStream *stream)

{

     if(instance == NULL)

{

         return NPERR_INVALID_INSTANCE_ERROR;

}

int32 rv = 1024;

     return rv;

}


int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)

{  

     if(instance == NULL)

     {

         return NPERR_INVALID_INSTANCE_ERROR;

}

     int32 iWrSize;

     if(fp)

     {

         iWrSize = fwrite(g_StreamBuf, 1, len, fp);

     }

 
     int32 rv = iWrSize;

     return rv;

}
 

NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)

{

     if(instance == NULL)

{

         return NPERR_INVALID_INSTANCE_ERROR;

} 

     if(fp)

     {

         fclose(fp);

         fp = NULL;

     }

     NPError rv = NPERR_NO_ERROR;

     return rv;

}