If you are using SMS 2003 (not SCCM 2007) you have the ability to perform a right click on query outputs. First you must have the Resource ID and Resource Type in the query output. Next you can ONLY have "System Resource" (SMS_R_System) queries. If you use SMS_G_System then the right click will not pass the parameter ###Sub:xxxx## to your application. In SCCM it just won't show you the right click menu correctly.
If you want to use a query to right click and start Resource Explorer/Remote tools you must that the Resource ID and Type in your query.