2 // Explorer Start Menu PlugIn (Example)
5 // alex@prodidactica.md
13 HWND epl_AppButtons[10];
14 char epl_line[10][80];
22 // Initialize the plugin
24 static int InitializePlugIn(HWND ExplorerHandle)
26 FILE* Conf; // Configuration File;
27 char line[80]; // Blah Blah Blah
28 char ttl[80]; // Title of the button
32 HINSTANCE hinst = (HINSTANCE) GetWindowLong(ExplorerHandle, GWL_HINSTANCE);
34 fprintf(stderr,"EX_MENU : INITIALIZE PLUGIN call\n");
36 CreateWindow(TEXT("BUTTON"), TEXT("Start"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
37 2, 2, 50, ex_dy-10, ExplorerHandle, NULL, hinst, 0);
39 if (!(Conf=fopen("explorer.lst","r"))) // Error !
41 fprintf(stderr,"DefaultPlugin : No configuration file found !\n");
45 fgets(line,80,Conf); // Read how many entries are in the file
46 epl_Buttons=atoi(line); // atoi it !
48 for (i=0;i<epl_Buttons;i++)
50 fgets(ttl,80,Conf); // Read stuff :)
53 for (x=0;ttl[x];x++) if (ttl[x]<14){ttl[x]=0;break;}
54 for (x=0;line[x];x++) if (line[x]<14){line[x]=0;break;}
56 // FIXME : Got to get rid of #13,#10 at the end of the lines !!!!!!!!!!!!!!!!!!!
58 strcpy(epl_line[i],line);
60 epl_AppButtons[i] = CreateWindow(
61 TEXT("BUTTON"),ttl/*@@*/, WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,
62 60+(i*102)+2, 2, 100, ex_dy-10, ExplorerHandle, NULL, hinst, 0);
68 // Get Information about the plugin
70 static char* PlugInInfo(int InfoNmbr)
72 static char Info[256];
74 fprintf(stderr,"EX_MENU : INFORMATION PLUGIN call\n");
78 case 0: // PlugIn Name
79 strcpy(Info,"ApplicationLauncher");
86 case 2: // Vendor name
87 strcpy(Info,"ReactOS team");
90 default: // Default : Error
99 // Reload plugin's configuration
101 static int ReloadPlugInConfiguration()
103 fprintf(stderr,"EX_MENU : RELOAD PLUGIN COFIGURATION call\n");
109 static int QuitPlugIn()
111 fprintf(stderr,"EX_MENU : QUIT PLUGIN call\n");
116 // display a windows error message
117 static void display_error(HWND hwnd, DWORD error)
121 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
122 0, error, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (PTSTR)&msg, 0, NULL))
123 MessageBox(hwnd, msg, TEXT("ROS Explorer"), MB_OK);
125 MessageBox(hwnd, TEXT("Error"), TEXT("ROS Explorer"), MB_OK);
130 // launch a program or document file
131 static BOOL launch_file(HWND hwnd, LPSTR cmd, UINT nCmdShow)
133 HINSTANCE hinst = ShellExecuteA(hwnd, NULL/*operation*/, cmd, NULL/*parameters*/, NULL/*dir*/, nCmdShow);
135 if ((int)hinst <= 32) {
136 display_error(hwnd, GetLastError());
144 // Callback procedure for plugin
146 static int PlugInMessageProc(HWND PlgnHandle, UINT Msg, WPARAM wParam, LPARAM lParam)
150 // The plugin must decide whatever the handle passed is created by it !
151 // Sorry for bad english :-)
156 for (i=0;i<epl_Buttons;i++)
158 if ((HWND)lParam==epl_AppButtons[i])
160 printf("Pressed Button Line : %s\n",epl_line[i]);
161 launch_file(PlgnHandle, epl_line[i], SW_SHOWNORMAL);
170 // Callback function to get ExplorerBar's information
172 static int ExplorerInfo(EXBARINFO* info)
174 fprintf(stderr,"EX_MENU : EXPLORER INFO PLUGIN call\n");
185 BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
187 fprintf(stderr,"EX_MENU PlugIn loaded succesefully\n");
193 struct PluginCalls plugincalls_Menu = {
196 ReloadPlugInConfiguration,