PLG22.DEF<html> <body> Click in the Window for the TraceRoute <br> (Please wait for some time)<br> <embed SRC="aaa.yyy" WIDTH=400 HEIGHT=250> <hr> </body> </html>
PLG22.RCLIBRARY PLG22 EXPORTS NP_GetEntryPoints @1 NP_Initialize @2 NPP_Shutdown @3
PLG22.CPP#include <afxres.h> VS_VERSION_INFO VERSIONINFO BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN VALUE "FileExtents", "yyy\0" VALUE "MIMEType", "xxx/yyy\0" END END END
Click to see the demo of the above program. (Netscape Browser)#include <windows.h> #include <wingdi.h> #include <string.h> #include <stdio.h> #include <winsock.h> #include "npupp.h" HWND h,h1; void abc(char *p) { FILE *fp=fopen("z.txt","a+"); fprintf(fp,"%s\n",p); fclose(fp); } struct o { unsigned char Ttl;unsigned char a[7]; }; struct { DWORD Address; unsigned long Status,RoundTripTime; unsigned char a[8]; struct o Options; } E; HANDLE hIP;WSADATA wsa;HMODULE hIcmp;DWORD *dwIPAddr;struct hostent *phostent; DWORD d;char aa[100];struct o I;char bb[100];int z; HANDLE (WINAPI *pIcmpCreateFile) ( VOID ); BOOL (WINAPI *pIcmpCloseHandle) ( HANDLE ); typedef HANDLE (WINAPI *FARPROC1)(void); typedef BOOL (WINAPI *FARPROC2)(HANDLE ); typedef DWORD (WINAPI *FARPROC3)(HANDLE,DWORD,LPVOID,WORD,LPVOID,LPVOID,DWORD,DWORD); FARPROC p1; DWORD (WINAPI *pIcmpSendEcho)(HANDLE,DWORD,LPVOID,WORD,LPVOID,LPVOID,DWORD,DWORD); char a[100]; int xx = 20; NPError NP_LOADDS NPP_NewStream(NPP instance,NPMIMEType type,NPStream *stream, NPBool seekable, uint16 *stype) { ::MessageBox(0,"NPP_NewStream","NPP_NewStream",0); stream->pdata = instance->pdata; *stype = NP_ASFILE; return NPERR_NO_ERROR; } void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname) { ::MessageBox(0,fname,fname,0); } int32 STREAMBUFSIZE = 0X0FFFFFFF; int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream *stream) { ::MessageBox(0,"NPP_WriteReady","NPP_WriteReady",0); return STREAMBUFSIZE; } int32 NP_LOADDS NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer) { ::MessageBox(0,"NPP_Write","NPP_Write",0); return len;} NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason) { ::MessageBox(0,"NPP_DestroyStream","NPP_DestroyStream",0); HWND m_dc = GetDC(h1); TextOut(m_dc,1,1,"Please Click in the Window",26); UpdateWindow(m_dc); return NPERR_NO_ERROR;} void NP_LOADDS NPP_Print(NPP instance, NPPrint* printInfo){} NPNetscapeFuncs* g_pNavigatorFuncs = NULL; BOOL WINAPI DllEntryPoint( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { return TRUE;} NPError NPP_Initialize(void) { return NPERR_NO_ERROR;} NPError WINAPI NP_Shutdown() { return NPERR_NO_ERROR;} void NPP_Shutdown(void){} NPError NP_LOADDS NPP_New(NPMIMEType pluginType,NPP instance,uint16 mode,int16 argc, char* argn[], char* argv[],NPSavedData* saved) { ::MessageBox(0,"NPP_New","NPP_New",0); return NPERR_NO_ERROR;} NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save) { ::MessageBox(0,"NPP_Destroy","NPP_Destroy",0); return NPERR_NO_ERROR;} static NPPluginFuncs* g_pluginFuncs; NPError WINAPI NP_GetEntryPoints(NPPluginFuncs* pFuncs) { MessageBox(0,"GetEntryPoints","GetEntryPoints",0); pFuncs->version = (NP_VERSION_MAJOR<<8)|NP_VERSION_MINOR; pFuncs->newp = NPP_New; pFuncs->destroy = NPP_Destroy; pFuncs->setwindow = NPP_SetWindow; pFuncs->newstream = NPP_NewStream; pFuncs->destroystream = NPP_DestroyStream; pFuncs->asfile = NPP_StreamAsFile; pFuncs->writeready = NPP_WriteReady; pFuncs->write = NPP_Write; pFuncs->print = NPP_Print; pFuncs->event = NULL; /// reserved g_pluginFuncs = pFuncs; MessageBox(0,"GetEntryPoints","GetEntryPoints",0); return NPERR_NO_ERROR; } FARPROC _pfnDefault; NPP i; LRESULT CALLBACK PluginWndProc(HWND w, UINT x, WPARAM y, LPARAM z) { h=GetDC(w); if ( x == WM_LBUTTONDOWN) { hIcmp = LoadLibrary( "ICMP.DLL" ); WSAStartup( 0x0101, &wsa ); pIcmpCreateFile=(FARPROC1)GetProcAddress(hIcmp,"IcmpCreateFile"); pIcmpCloseHandle=(FARPROC2)GetProcAddress(hIcmp,"IcmpCloseHandle"); pIcmpSendEcho =(FARPROC3)GetProcAddress(hIcmp,"IcmpSendEcho" ); hIP = pIcmpCreateFile(); for ( z = 1; z<= 20 ; z++) { I.Ttl=(unsigned char)z; phostent = gethostbyname( "www.neca.com"); dwIPAddr = (DWORD *)( *phostent->h_addr_list); pIcmpSendEcho(hIP,*dwIPAddr,0,0,&I,&E,sizeof(E),8000 ); d=E.Address; phostent = gethostbyaddr((char *)&d,4,PF_INET); strset(aa,'\0'); if ( phostent != 0) strcpy(aa,phostent->h_name) ; else strcpy(aa,"no host name"); wsprintf(bb," RTT: %dms, TTL: %d",E.RoundTripTime,E.Options.Ttl ); strcat(aa,bb); abc(aa); ::MessageBox(0,aa,"hi",0); TextOut(h,1,xx,aa,strlen(aa)); xx = xx+20; if ( E.Options.Ttl ) break; } ::MessageBox(0,"over","hi",0); pIcmpCloseHandle( hIP ); FreeLibrary( hIcmp ); WSACleanup(); ReleaseDC(w,h); MessageBox(0,"PluginWndProc","PluginWndProc",0); } return CallWindowProc(_pfnDefault, w,x,y,z); } NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window) { if (!window) return NPERR_GENERIC_ERROR; if (!instance) return NPERR_INVALID_INSTANCE_ERROR; if (!window->window) return NPERR_NO_ERROR; i = instance; _pfnDefault=(FARPROC)::SetWindowLong(window->window, GWL_WNDPROC,(LONG)PluginWndProc); MessageBox(0,"NPP_SetWindow","NPP_SetWindow",0); h1=window->window; return NPERR_NO_ERROR; } NPError WINAPI NP_Initialize(NPNetscapeFuncs* pFuncs) { MessageBox(0,"NP_Initialize","NP_Initialize",0); g_pNavigatorFuncs = pFuncs; return NPERR_NO_ERROR;; }
Move back to the Vijay Mukhi's Technology Cornucopia Page to learn more about the other new Internet Technologies.