一组VC开发PL/SQL Developer插件代码骨架

    PL/SQL Developer因其较完整的Oracle数据库开发和管理功能而广泛被诸多MIS程序员和DBA采用,随着应用的深入,应用提供的功能可能不在能满足当前的快速开发或维护的需求,和其它软件类似,该应用程序也提供通过插件开发扩展功能办法,尽管在编辑窗口方面没什么便利而言,并且官方提供有第三方开发的有用插件下载,如ExecuteNotifier就是一个超简单且很实用的插件,尤其是对并行执行工作任务的人员。废话少说接下来说一下插件的开发办法。

    安装目录的PlugInDoc目录下的plugindoc.pdf文档简要介绍了插件的开发方法和插件函数的IDE函数的说明,尽管文档比较晦涩,不过也就是唯一的可参考的文档了。该目录下同时提供了几个简单示例和几个接口文件,可以直接应用于插件的开发,值得一提的是Delphi部分还算靠谱,VC++的接口文件函数编号直接是混乱,建议直接启用该文件自己整理,不然得不偿失,调试时根本无法区分是自己的代码问题还是函数指针正确性的问题,毕竟该工具是用Delphi开发,开发者可能不太喜欢VC++开发应用,连官方给出的接口文件都没人验证过,而Delphi和BCB的结构文件函数包含不完整,因此如果要深入开发插件没办法直接使用这些接口文件。于是乎本人自己整理了分别整理这三个开发工具使用的接口文件,只因机器迁移的原因Delphi和BCB文件已经丢失,在另外一篇博文中保留了一部分,其中视图将所有结构调用通过Lua语言的方式延伸出来,缩短开发过程中编译和发布的困难,接口函数相对完整。

    现在单独放出一组接口文件,其中还包含了自己开发的几个简单的功能:拷贝表字段列表、拷贝单表查询语句和循环试用的代码,希望能抛砖引玉,为想在PL/SQL Developer中开发自己插件的同仁提供一些便利,毕竟官方没有提供正确的接口文件,且没有任何数据库或应用用于生成这些接口文件,本人徒手整理了接口文件,版本覆盖到当前发布的最新版本,即9.0.6.1161。

 

// mytools.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include <ATLComTime.h> 
#include <Strsafe.h>

/*PlugIn ID*/
int nPlugID;

/************************************************************************/
/* User defined types                                                   */
/************************************************************************/
#define MID_SEPARATOR_1		1
#define MID_SEPARATOR_2		2
#define MID_SEPARATOR_3		3
#define MID_SEPARATOR_4		4
#define MID_SEPARATOR_5		5
#define MID_SEPARATOR_6		6
#define MID_SEPARATOR_7		7
#define MID_SEPARATOR_8		8
#define MID_SEPARATOR_9		9
#define MID_SEPARATOR_10	10

#define MID_COPY_COLS2CB	11
#define MID_COPY_SEL2CB		12

#define MAX_CLIPBOARD_LENGTH	300*30*4

#define MAX_NAME_LENGTH	30

/************************************************************************/
/* SYSTEM Info functions                                                */
/************************************************************************/
/*
Returns the PL/SQL Developer main and subversion, for example 210
for version 2.1.0. This might be useful if you want to use functions that
are not available in all versions.
*/
int (*SYS_Version)();

/*
Returns the registry root name of PL/SQL Developer in
HKEY_CURRENT_USER (usually “Software\PL/SQL Developer”). If you
want to save your settings in the registry, you can create a section within
the PL/SQL Developer section.
Note: In PL/SQL Developer 3.1, the registry section is moved to:
(“Software\Allround Automations\PL/SQL Developer”)
*/
char* (*SYS_Registry)();

/*
The directory where PL/SQL Developer is installed, for example
“C:\Program Files\PLSQL Developer”.
*/
char* (*SYS_RootDir)();

/*
The Oracle directory, for example “C:\Orawin95”
*/
char* (*SYS_OracleHome)();

/*
Returns the path of the OCI DLL that is used by PL/SQL Developer. If
you want to initialize a new session, you might want to use this value if
you want to make sure you’re using the same OCI version.
*/
char* (*SYS_OCIDLL)();

/*
Returns True if PL/SQL Developer is currently connected in OCI8 Mode
(Net8).
*/
BOOL* (*SYS_OCI8Mode)();

/*
Returns if PL/SQL Developer is currently using the visual XP style.
*/
BOOL* (*SYS_XPStyle)();

/*
If Param is empty, the function will return the full tnsnames filename.
If Param has a value, the connection details of the alias as specified by
Param is returned. If Param is *, the connection details of the current
connection are returned). The return value can look like:
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = p2800)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = AAA)
)
)
*/
char* (*SYS_TNSNAMES) (char *Param);

/*
Returns the Delphi version used to build PL/SQL Developer. Only useful
for very specific functions.
*/
int (*SYS_DelphiVersion)();

/************************************************************************/
/* IDE functions                                                        */
/************************************************************************/
/*
Use this function to enable or disable a menu. The ID is the Plug-In ID,
which is given by the IdentifyPlugIn function. The Index is the menu
index, which the menu was related to by the CreateMenuItem function.
The Enabled boolean determines if the menu item is enabled or grayed.
*/
void (*IDE_MenuState)(int ID, int Index, BOOL Enabled);

/*
Returns a boolean that indicates if PL/SQL Developer is currently
connected to a database.
*/
BOOL (*IDE_Connected)();

/*
Returns the username, password and database of the current
connection.
*/
void (*IDE_GetConnectionInfo)(char **Username, char **Password, char **Database);

/*
Returns information about the selected item in the Browser. If no item is
selected, all items are empty.
*/
void (*IDE_GetBrowserInfo)(char **ObjectType, char **ObjectOwner, char **ObjectName);

/*
Returns the type of the current window.
1 = SQL Window
2 = Test Window
3 = Procedure Window
4 = Command Window
5 = Plan Window
6 = Report Window
0 = None of the above
*/
int (*IDE_GetWindowType)();

/*
Returns the Application handle of PL/SQL Developer
*/
int (*IDE_GetAppHandle)();

/*
Returns the handle of PL/SQL Developers main window
*/
int (*IDE_GetWindowHandle)();

/*
Returns the handle of PL/SQL Developers client window
*/
int (*IDE_GetClientHandle)();

/*
Returns the handle of the active child form
*/
int (*IDE_GetChildHandle)();

/*
Resets the state of the menus, buttons and the active window.
You can call this function if you made some changes that affect the state
of a menu or window which are unnoticed by PL/SQL Developer.
*/
void (*IDE_Refresh)();

/*
Creates a new window. The Text parameter contains text that is placed
in the window. If the Execute Boolean is true, the Window will be
executed.
WindowType can be one of the following values:
1 = SQL Window
2 = Test Window
3 = Procedure Window
4 = Command Window
5 = Plan Window
6 = Report Window
Version 800 and higher
7 = HTML Window
*/
void (*IDE_CreateWindow)(int WindowType, char *Text, BOOL Execute);

/*
Creates a window of type WindowType and loads the specified file.
WindowType can be one of the following values:
1 = SQL Window
2 = Test Window
3 = Procedure Window
4 = Command Window
The function returns True if successful.
Version 301 and higher
If you pass 0 as WindowType, PL/SQL Developer will try to determine
the actual WindowType on the extension of the filename.
Version 800 and higher
5 = Plan Window
6 = Report Window
7 = HTML Window
*/
BOOL (*IDE_OpenFile)(int WindowType, char *Filename);

/*
This function saves the current window. It returns True if successful.
*/
BOOL (*IDE_SaveFile)();

/*
Return the filename of the current child window.
See also IDE_SetFilename()
*/
char* (*IDE_Filename)();

/*
Closes the current child window
*/
void (*IDE_CloseFile)();

/*
Set the ReadOnly status of the current Window
*/
void (*IDE_SetReadOnly)(BOOL ReadOnly);

/*
Get the ReadOnly status of the current Window
*/
BOOL (*IDE_GetReadOnly)();

/*
This function will execute a query (SQL parameter) and display the result
in a ‘result only’ SQL Window. Title will be used as the window name and
the Updateable parameter determines if the results are updateable.
*/
BOOL (*IDE_ExecuteSQLReport)(char *SQL,	char *Title, BOOL Updateable);

/*
Forces the active child window to reload its file from disk.
Note: In PL/SQL Developer 4 there will no longer be a warning message
when modifications were made.
*/
BOOL (*IDE_ReloadFile)();

/*
Set the filename of the active child window. The filename should contain
a valid path, but the file does not need to exist. The new filename will be
used when the file is saved.
If the Filename parameter is an empty string, the Window will behave as
a new created Window.
*/
void (*IDE_SetFilename)(char *Filename);

/*
Retrieves the text from the current child window.
*/
char* (*IDE_GetText)();

/*
Retrieves the selected text from the current child window.
*/
char* (*IDE_GetSelectedText)();

/*
Retrieves the word the cursor is on in the current child window.
*/
char* (*IDE_GetCursorWord)();

/*
Returns the handle of the editor of the current child window.
*/
int (*IDE_GetEditorHandle)();

/*
Sets the text in the editor of current window. If this failed for some reason
(ReadOnly?), the function returns false.
*/
BOOL (*IDE_SetText)(char *Text);

/*
Places a message in the status bar of the current window, returns false if
the window did not have a status bar.
*/
BOOL (*IDE_SetStatusMessage)(char *Text);

/*
Highlights the given line and places the cursor at the given position.
This will only work when the active window is a procedure window, if not,
the function returns false.
*/
BOOL (*IDE_SetErrorPosition)(int Line, int Col);

/*
Resets the highlighted lines.
*/
void (*IDE_ClearErrorPositions)();

/*
This function returns the location of the cursor in the word after a call to
IDE_GetCursorWord. Possible return values:
0: Unknown
1: Cursor was at start of word
2: Cursor was somewhere in the middle
3: Cursor was at the end
*/
int (*IDE_GetCursorWordPosition)();

/*
This function allows you to perform a specific action as if the menu item
as specified in Param was selected. The following values are supported:
1: Execute
2: Break
3: Kill
4: Commit
5: Rollback
6: Print
*/
BOOL (*IDE_Perform)(int Param);

/*
Returns a list of all keywords as entered in the ‘custom keywords’ option
in the Editor preference.
*/
char* (*IDE_GetCustomKeywords)();

/*
Fills the custom keywords with the words in the Keywords parameter.
Words should be separated by cr/lf. The currently used keywords will be
overwritten.
*/
void (*IDE_SetCustomKeywords)(char *Keywords);

/*
Adds a number of keywords with a specific style.
This function is more specific then IDE_SetCustomKeywords because
this one can set multiple sets of keywords for different highlighting styles.
ID should be the PlugIn ID as returned by the IdentifyPlugIn function.
Style can be one of the following values:
10: Custom
11: Keywords
12: Comment
13: Strings
14: Numbers
15: Symbols
Keywords is a cr/lf separated list of words. You can define one list per
style.
*/
void (*IDE_SetKeywords)(int ID, int Style, char *Keywords);

/*
Activates the keywords as defined by the IDE_SetKeywords function.
*/
void (*IDE_ActivateKeywords)();

/*
When this function is called, all menus for this Plug-In are removed and
CreateMenuItem will be called to build a new set of menus. This only
makes sense if you supply a different set of menu-items.
*/
void (*IDE_RefreshMenus)(int ID);

/*
This function allows you to rename a certain menu-item.
ID is the Plug-In ID, Index is the Menu number and name is the new
menu name.
*/
void (*IDE_SetMenuName)(int ID, int Index, char *Name);

/*
You can display or remove a check mark for a menu-item.
*/
void (*IDE_SetMenuCheck)(int ID, int Index,	BOOL Enabled);

/*
With this function you can hide or show a specific menu. You can use
this instead of IDE_MenuState.
*/
void (*IDE_SetMenuVisible)(int ID, int Index, BOOL Enabled);

/*
Returns a list of all standard PL/SQL Developer menu items. Items are
separated by cr/lf and child menu level is indicated by a number of
spaces.
You can use this function to build an advanced user configuration dialog
where the user could be able to select place where he wants to insert the
Plug-In menus.
*/
char* (*IDE_GetMenulayout)();

/*
With this function you can add items to certain popup menus. The ID is
the Plug-In ID and the index is the menu index. You can pass any
number as the menu index, it can be an existing menu (as used by
CreateMenuItem) or anything else. If the popup menu gets selected,
OnMenuClick is called with the corresponding index.
The Name is the menu name as it will be displayed. The ObjectType
determines in which popup menus this item will be displayed. Some
possible values are: ‘TABLE’, ‘VIEW’, ‘PACKAGE’, etc.
Version 301 and higher
If you pass one of the following values as ObjectType, you can add items
to specific Windows.
PROGRAMWINDOW
SQLWINDOW
TESTWINDOW
COMMANDWINDOW
Version 400 and higher
You can add popup items to Object Browser items like Tables, Views,
etc. by passing their name as ObjectType.
Version 510 and higher
If you want to create popup menus for multiple selected items (of the
same object type), you can add a + to the ObjectType parameter like
‘TABLE+’, ‘VIEW+’, etc. The OnMenuClick will be called for every
selected item, and the GetPopupObject will return the correct details.
Version 700 and higher
Supports Popup for the Session Window with the SESSIONWINDOW
ObjectType. (see also IDE_GetSessionValue)
Version 712 and higher
Supports Popup for result grids with SQLRESULT
Version 800 and higher
Supports Popup for file browser with FILE
*/
void* (*IDE_CreatePopupItem)(int ID, int Index, char *Name, char *ObjectType);

/*
This function allows you to reconnect PL/SQL Developer as another
user. The return value indicates if the connection was successful.
The function will fail if there is a childwindow with an active query.
Also see IDE_SetConnectionAs
*/
BOOL (*IDE_SetConnection)(char *Username, char *Password, char *Database);

/*
This function returns Oracle information about the item in the AnObject
parameter. The SubObject returns the name of the procedure if the
Object is a packaged procedure.
*/
int (*IDE_GetObjectInfo)(char *AnObject,
	char **ObjectType, char **ObjectOwner,
	char **ObjectName, char **SubObject);

/*
Returns a cr/lf separated list of items from the Object Browser. The Node
parameter determines which items are returned. This can be one of the
main items like TABLES, but you can also us a slash to get more specific
items like TABLES/DEPT/COLUMNS.
The GetItems boolean determines if PL/SQL Developer will fetch these
values from the database if the item has not been opened yet in the
Browser.
*/
char* (*IDE_GetBrowserItems)(char *Node, BOOL GetItems);

/*
Force a refresh to the Object Browser. If Node is empty, all items are
refreshed. To refresh a specific item you can enter the name in the Node
parameter.
Note:
Version 500 allows you to pass a * to refresh the current selected
browser item.
Note:
Version 600 allows you to pass a ** to refresh to parent of the current
browser item, and you can pass *** to refresh to root item.
*/
void (*IDE_RefreshBrowser)(char *Node);

/*
This function returns information about the item for which a popup menu
(created with IDE_CreatePopupItem) was activated.
If the item is a Browser folder, the name of the folder will be returned in
ObjectName and ObjectType will return ‘FOLDER’
*/
int (*IDE_GetPopupObject)(char **ObjectType,
	char **ObjectOwner, char **ObjectName,
	char **SubObject);

/*
This function returns the name of browser root item for which a popup
menu (created with IDE_CreatePopupItem) was activated.
*/
char* (*IDE_GetPopupBrowserRoot)();

/*
If you modify database objects in your Plug-In and you want to update
PL/SQL Developer to reflect these changes, you can do so by calling this
function. You should pass the object type, owner, name and the action
that you performed on the object. The action can be one of the following:
1 = Object created
2 = Object modified
3 = Object deleted
PL/SQL Developer will update the browser and all windows that might
use the object.
*/
void (*IDE_RefreshObject) (char *ObjectType,
	char *ObjectOwner, char *ObjectName,
	int Action);

/*
This function will return the details of the first selected in the Browser.
The function will return false if no items are selected.
Use in combination with IDE_NextSelectedObject to determine all
selected items.
*/
BOOL (*IDE_FirstSelectedObject) (char *ObjectType,
	char *ObjectOwner, char *ObjectName, char *SubObject);

/*
This function can be called after a call to IDE_FirstSelectedObject to
determine all selected objects. You can keep calling this function until it
returns false.
*/
BOOL (*IDE_NextSelectedObject) (char *ObjectType,
	char *ObjectOwner, char *ObjectName, char *SubObject);

/*
Returns the source for the specified object. This function will only return
source for objects that actually have source (packages, views, …).
*/
char* (*IDE_GetObjectSource)(char *ObjectType,
	char *ObjectOwner, char *ObjectName);

/*
Returns the number of child windows in PL/SQL Developer. In
combination with IDE_SelectWindow you can communicate with all child
windows.
*/
int (*IDE_GetWindowCount)();

/*
This function will ‘select’ one of PL/SQL Developers child Windows.
Index is the window number where 0 is the top child window. The return
value will indicate if the window existed.
Normally all window related functions communicate with the active child
window. With this function you can select any window and all windowrelated
IDE functions will refer to the selected window.
Note:
IDE_SelectWindow does not actually bring the window to front, you need
IDE_ActivateWindow to do that.
*/
BOOL (*IDE_SelectWindow)(int Index);

/*
Brings the Indexth child window with to front.
*/
BOOL (*IDE_ActivateWindow)(int Index);

/*
Returns if the contents of the window is modified.
*/
BOOL (*IDE_WindowIsModified)();

/*
Returns if there is anything running in the current window.
*/
BOOL (*IDE_WindowIsRunning)();

/*
Creates an empty splash screen (the one you see when PL/SQL
Developer is starting or printing) which allows you to show some kind of
progress on lengthy operations.
If the ProgressMax parameter is larger then 0, a progress bar is
displayed which you can advance with the IDE_SplashProgress function.
Note:
There can only be one splash screen active at a time. If a splash screen
is created while one was active, the first one will get re-used.
*/
void (*IDE_SplashCreate)(int ProgressMax);

/*
Hides the splash screen. This function will work on any splash screen,
you can even hide the one created by PL/SQL Developer.
*/
void (*IDE_SplashHide)();

/*
Add text to the splash screen.
*/
void (*IDE_SplashWrite)(char *s);

/*
Add text to the splash screen beginning on the next line.
*/
void (*IDE_SplashWriteLn)(char *s);

/*
If the splash screen was created with a progress bar, you can indicate
progress with this function.
*/
void (*IDE_SplashProgress)(int Progress);

/*
This function returns the path where the templates are located.
*/
char* (*IDE_TemplatePath)();

/*
If you want to execute a template from within your PlugIn you can do so
with this function. The NewWindow parameter indicates if a new window
should be created or that the result of the template should be pasted at
the current cursor position in the active window. The template parameter
should contain the template name. If the template is located in one or
more folders, the folder name(s) should be prefixed to the template
name separated by a backslash.
*/
BOOL (*IDE_ExecuteTemplate)(char *Template,BOOL NewWindow);

/*
Use this function to determine if the current connection has a specific
‘Connect As’. Possible return values are:
'', 'SYSDBA' and 'SYSOPER'
*/
char (*IDE_GetConnectAs)();

/*
Identical to IDE_SetConnection, but with an option to specify a
ConnectAs parameter. You can pass 'SYSDBA' or 'SYSOPER', all other
values will be handled as 'NORMAL'.
*/
BOOL (*IDE_SetConnectionAs)(char *Username,
	char *Password, char *Database, char *ConnectAs);

/************************************************************************/
/* External FileSystem functions                                        */
/************************************************************************/
/*
If you want to create a new ‘File Open’ menu with the same items as the
standard menu, you can use this function to determine the standard
items. You can call this function in a loop while incrementing MenuIndex
(starting with 0) until the return value is an empty string. The return
values are the menu names in the File Open menu and the WindowType
is the corresponding window type.
*/
char* (*IDE_GetFileOpenMenu)(int MenuIndex, int *WindowType);

/*
Returns True if the active child window can be saved. (which are the
SQL, Test, Program and Command windows).
*/
BOOL (*IDE_CanSaveWindow)();

/*
Creates a new Window (of type WindowType) for the specified (and
registered) FileSystem, Tag and Filename.
*/
void (*IDE_OpenFileExternal)(int WindowType, char *Data,
	char *FileSystem, char *Tag, char *Filename);

/*
Returns the defined filetypes for a specific WindowType.
*/
char* (*IDE_GetFileTypes)(int WindowType);

/*
Returns the default extension (without period) for a specific window type.
*/
char* (*IDE_GetDefaultExtension)(int WindowType);

/*
Returns the data of a window. You can use this function to get the data
and save it.
*/
char* (*IDE_GetFiledata)();

/*
You can call this function when a file is saved successfully. The filename
will be set in the Window caption and the status will display that the file is
‘saved successfully’.
FileSystem and FileTag can be nil.
*/
void (*IDE_FileSaved)(char *FileSystem, char *FileTag,	char *Filename);

/*
This function displays a html file in a child window. The url parameter
identifies the file and the hash parameter allows you to jump to a specific
location. The title parameter will be used as window title.
You can refresh the contents of an already opened window by specifying
an ID. If ID is not empty, and a window exists with the same ID, this will
be used, otherwise a new window will be created.
*/
BOOL (*IDE_ShowHTML)(char *Url, char *Hash,	char *Title, char *ID);

/*
Refresh the contents of a HTML Window. You can pass an url to refresh
all windows that show a specific url, or you can pass an ID to refresh a
specific Window.
*/
BOOL (*IDE_RefreshHTML)(char *Url, char *ID, BOOL BringToFront);

/*
Returns the define file extension of a specific object type. The oType
parameter can hold one of the following valies:
FUNCTION, PROCEDURE, TRIGGER,
PACKAGE, PACKAGE BODY, PACKAGE SPEC AND BODY,
TYPE, TYPE BODY, TYPE SPEC AND BODY,
JAVA SOURCE
*/
char* (*IDE_GetProcEditExtension) (char *oType);

/*
Get info about the object opened in a Window. This will only work for
Program Windows.
*/
BOOL (*IDE_GetWindowObject) (char **ObjectType,
	char **ObjectOwner, char **ObjectName,
	char **SubObject);

/*
Returns the first selected item in the file browser. Use
IDE_NextSelectedFile for multiple selected items. The Files and
Directories parameters allow you to specify if you do or don’t want
selected files and/or directories.
*/
char* (*IDE_FirstSelectedFile)(BOOL Files, BOOL	Directories);

/*
Returns the next selected item. See the previous function.
Returns empty value when no more items.
*/
char* (*IDE_NextSelectedFile)();

/*
Forces the file browser to refresh the contents. Normally the browser will
autodetect changes.
*/
void (*IDE_RefreshFileBrowser)();

/*
Simulates a key press. You can use this function to do the things you
can also do with the keyboard. The Key parameter is the virtual key code
of the key, and the Shift parameter holds the status of the Shift Ctrl and
Alt keys. You can combine the following values:
1 = Shift
2 = Alt
3 = Ctrl
*/
void (*IDE_KeyPress)(int Key, int Shift);

/*
This function will return an ‘index’ of a specific menu item. The
MenuName parameter must specify the menu path separated by a slash,
for example ‘edit / selection / uppercase’. The menu name is not case
sensitive. If the function returns zero, the menu did not exist.
You can use the return value with IDE_SelectMenu
*/
int (*IDE_GetMenuItem)(char *MenuName);

/*
You can execute a menu item with this function. The MenuItem
parameter has to be determined by the IDE_SelectMenu function. If this
function returns false, the menu did not exist, or it was disabled.
*/
BOOL (*IDE_SelectMenu)(int MenuItem);

/*
Returns the currently used translation file. If the return value is empty, no
translation is used.
*/
char* (*IDE_TranslationFile)();

/*
Returns the language of the currently used translation file. If the return
value is empty, no translation is used.
*/
char* (*IDE_TranslationLanguage)();

/*
Returns a list of all standard PL/SQL Developer menu items like
IDE_GetMenuLayout, but this function will return the translated menus.
*/
char* (*IDE_GetTranslatedMenuLayout)();

/*
Return the PL/SQL Developer main font in the format:
“Name”, size, color, charset, “style”
*/
char* (*IDE_MainFont)();

/*
Function for translating items.
*/
char* (*IDE_TranslateItems)(char *Group);

/*
Function for translating items.
*/
char* (*IDE_TranslateString)(char *ID, char *Default, char
	Param1, char Param2);

/*
PL/SQL Developer has a preference to save all opened files on a time
interval, and/or when an Execute is performed. In case of a crash (from
the system, Oracle or PL/SQL Dev), the user will be able to recover the
edited files.
If the Plug-In can do things that have a possible risk of causing a crash,
you can call this function to protect the user’s work.
*/
BOOL (*IDE_SaveRecoveryFiles)();

/*
Returns the (1 based) character position of the cursor in the current
editor.
*/
int (*IDE_GetCursorX)();

/*
Returns the (1 based) line position of the cursor in the current editor.
*/
int (*IDE_GetCursorY)();

/*
Set the cursor in the current editor. If the X or Y parameter is 0, the
position will not change.
This function will also update the position display in the statusbar.
*/
void (*IDE_SetCursor)(int X, int Y);

/*
Create a bookmark at position X (character), Y (line). Index is the
bookmark (0..9) you want to set. If you pass –1 as bookmark, the first
free bookmark will be used. The returned value is the used bookmark.
Normally, from within PL/SQL Developer. Bookmarks can only be used
for windows with a gutter (Test window and Program editor), but the
Plug-In interface allows you to use bookmarks for all windows.
*/
int (*IDE_SetBookmark)(int Index, int X, int Y);

/*
Clears the specified bookmark
*/
void (*IDE_ClearBookmark)(int Index);

/*
Jumps to a bookmark
*/
void (*IDE_GotoBookmark)(int Index);

/*
Get the cursor position for a specific bookmark
*/
BOOL (*IDE_GetBookmark)(int Index, int X, int Y);

/*
Returns the description tab page Index (zero based). The return value is
empty if the tab page does not exist. This function allows you to
determine which tab pages (if any) are available for the current window.
*/
char* (*IDE_TabInfo)(int Index);

/*
This function allows you to read or set the active tab page. To set a
specific page, pass a zero based value to the Index parameter. The
return value is the actual selected page. To determine the active page
(without setting it) pass a value of –1 to the Index parameter.
*/
int (*IDE_TabIndex)(int Index);

/*
This function allows you to add Toolbuttons to your Plug-In, similar to
IDE_CreatePopupItem. The ID is the Plug-In ID and the index is the
menu index. When a button is selected, OnMenuClick is called with the
corresponding index.
The Name will appear as hint for the button, and as name in the
preferences dialog.
The button can be enabled and disabled with IDE_MenuState.
The image for the button can be set by passing a filename to a bmp file
in the BitmapFile parameter, or as a handle to a bitmap in memory.
The bmp image can have any number of colors, but should
approximately be 20 x 20 pixels in size.
The button will only be visible if it is selected in the Toolbar preference.
*/
void (*IDE_CreateToolButton)(int ID, int Index, char *Name,
	char *BitmapFile, int BitmapHandle);

/*
Returns true if the current Window has an Editor. If the CodeEditor
parameter is true, it returns false for editors like the output editor.
*/
BOOL (*IDE_WindowHasEditor)(BOOL CodeEditor);

/*
Returns the PL/SQL Beautifier options. The result is a value where the
following values are or-ed together:
1 AfterCreating enabled
2 AfterLoading enabled
4 BeforeCompiling enabled
8 BeforeSaving enabled
You can use this to determine if you need to call the beautifier.
*/
int (*IDE_BeautifierOptions)();

/*
Calls the PL/SQL Beautifier for the current Window. The result indicates
if the operations succeeded.
*/
BOOL (*IDE_BeautifyWindow)();

/*
Calls the PL/SQL Beautifier to beautify the text in the S parameter. The
result is the beautified text or it is empty if the function failed
*/
char* (*IDE_BeautifyText)(char *S);

/*
This function allows you to do a specific action for the object specified.
The following actions are available:
VIEW, VIEWSPECANDBODY, EDIT, EDITSPECANDBODY, EDITDATA,
QUERYDATA, TEST
*/
BOOL (*IDE_ObjectAction)(char *Action, char *ObjectType,
	char *ObjectOwner, char *ObjectName);

/*
This allows you to start a specific PL/SQL Developer dialog. The
following are supported:
AUTHORIZATIONS
PROJECTITEMS
BREAKPOINTS
PREFERENCES
CONFIG PLUGINS
CONFIG TOOLS
CONFIG DOCUMENTS
CONFIG REPORTS
CONFIG MACROS
CONFIG AUTOREFRESH
The Param parameter is for future use.
*/
BOOL (*IDE_ShowDialog) (char *Dialog, char *Param);

/*
When debuggin is on, this function allows you to add messages in the
debug.txt file generated.
*/
void (*IDE_DebugLog)(char *Msg);

/*
This function returns a command-line parameter, or a parameter
specified in the params.ini file.
*/
char* (*IDE_GetParamString)(char *Name);

/*
This function returns a command-line parameter, or a parameter
specified in the params.ini file.
*/
BOOL (*IDE_GetParamBool)(char *Name);

/*
This function returns the defined browser filters. You can use this if the
Plug-in has a similar requirement. Index = 0 and higher, and the returned
values are empty if the filter does not exist.
*/
void (*IDE_GetBrowserFilter)(int Index, char **Name,
	char **WhereClause, char **OrderByClause, char **User,
	BOOL Active);

/*
This function allows you to return feedback to the command window. The
description S will be displayed in the window identified by the
FeedbackHandle. See the CommandLine Plug-In function for details.
*/
void (*IDE_CommandFeedback)(int FeedbackHandle,	char *S);

/*
Returns the number of rows in the result grid of a SQL or Test Window.
*/
int (*IDE_ResultGridRowCount)();

/*
Returns the number of cols in the result grid of a SQL or Test Window.
*/
int (*IDE_ResultGridColCount)();

/*
This function allows you to access the results of a query in a SQL or Test
Window. Use the above two functions to determine the number of rows
and cols.
*/
char* (*IDE_ResultGridCell)(int Col, int Row);

/*
In PL/SQL Developer 6 we introduced the concept of Authorization. You
should test if a specific feature is allowed for the current user with this
function. In the Category parameter you can specify one of the main
categories (objects, menus, system). The name parameter specifies the
item (session.kill or objects.drop). Some items have a subname, like
objects.drop with the different objects.
*/
BOOL (*IDE_Authorized)(char * Category, char
	*Name, char *SubName);

/*
For a quick check if authorization allows the Plug-In to create a specific
function, you can use this function.
*/
BOOL (*IDE_WindowAllowed)(int WindowType, BOOL ShowErrorMessage);

/*
Returns if authorization is enabled or not.
*/
BOOL (*IDE_Authorization)();

/*
If you want a list off all available authorization items, you can call this
function. It will return a cr/lf separated list.
*/
char* (*IDE_AuthorizationItems)(char *Category);

/*
If you want to add items to the authorization list to allow them to be
managed through the authorization option, you can use this function.
Pass the PlugInID to identify your Plug-In, and pass the Name parameter
with the item you want to add. The name should be unique, so you
should prefix it with the name the Plug-In, for example:
MyPlugIn.Create New Command
All items will be added in the PlugIns category, so if you want to
test if this feature is allowed you should call:
IDE_Authorized('PlugIns ', ' MyPlugIn.Create New Command')
*/
void (*IDE_AddAuthorizationItem)(int PlugInID, char	*Name);

/*
Returns a list of all personal preference sets.
If you to have the Plug-In to use different preferences depending on the
current connection, you can use this function to build a list of possible
preference sets.
*/
char* (*IDE_GetPersonalPrefSets)();

/*
Returns a list of all default preference sets.
*/
char* (*IDE_GetDefaultPrefSets)();

/*
Read a Plug-In preference from the preferences. In PL/SQL Developer
6, personal preferences are stored in files, not in the registry. You can
still use the registry, but if you want to store your preferences in a shared
location, you can use this function.
Pass the PlugInID you received with the IdentifyPlugIn call. The PrefSet
parameter can be empty to retrieve default preferences, or you can
specify one of the existing preference sets.
*/
char* (*IDE_GetPrefAsString)(int PlugInID, char * PrefSet,
	char *Name, char *Default);

/*
As IDE_GetPrefAsString, but for integers.
*/
int (*IDE_GetPrefAsInteger)(int PlugInID, char * PrefSet,
	char *Name, BOOL Default);

/*
As IDE_GetPrefAsString, but for booleans.
*/
BOOL (*IDE_GetPrefAsBool)(int PlugInID, char * PrefSet,
	char *Name, BOOL Default);

/*
Set a Plug-In preference. Pass the PlugInID you received with the
IdentifyPlugIn call. The PrefSet parameter can be empty to set default
preferences, or you can specify one of the existing preference sets. The
return value indicates if the function succeeded.
*/
BOOL (*IDE_SetPrefAsString)(int PlugInID, char *PrefSet,
	char *Name, char *Value);

/*
As IDE_SetPrefAsString, but for integers.
*/
BOOL (*IDE_SetPrefAsInteger)(int PlugInID, char *PrefSet,
	char *Name, int Value);

/*
As IDE_SetPrefAsString, but for booleans.
*/
BOOL (*IDE_SetPrefAsBool)(int PlugInID, char *PrefSet,
	char *Name, BOOL Value);

/*
Returns the value of a preference. The names can be found in the
preference ini file under the [Preferences] section.
*/
char* (*IDE_GetGeneralPref)(char *Name);

/*
Make a Plug-In specific setting:
NOFILEDATECHECK TRUE|FALSE
Determines if PL/SQL Developer checks for changes in files
(default true)
CHARMODE ANSI|UTF8|UTF8BOM
Determines how PChar parameters are passed through the Plug-In
interface. Since version 7.1 supports editing of Unicode, but the interface
only supports normal characters, you can choose to support UTF8
encoding. The UTF8BOM encoding will precede the characters with a
BOM indicator when text contains Unicode.
*/
BOOL (*IDE_PlugInSetting)(int PlugInID, char *Setting, char *Value);

/*
Returns the number of overloads for a specific procedure.
Result < 0 = Procedure doesn't exist
Result > 0 = overload count
*/
int (*IDE_GetProcOverloadCount) (char *Owner, char
	*PackageName, char *ProcedureName);

/*
Shows a dialog to allow the user to select an overloaded procedure.
Result < 0 = Cancel
Result 0 = No overloadings
Result > 0 = Overload index
*/
int (*IDE_SelectProcOverloading) (char *Owner, char
	*PackageName, char *ProcedureName);

/*
This function will return one of the Session parameters as you see in the
grid of the session tool. You will only get a result if the Session Window
is active, so this will only work from a Popup menu created for the
SESSIONWINDOW object.
*/
char* (*IDE_GetSessionValue) (char *Name);

/*
You can use this function to check if the database is equal or higher then
the specified version. The parameter should be in the format aa.bb, like
09.02 or 10.00.
*/
BOOL (*IDE_CheckDBVersion)(char *Version);

/************************************************************************/
/* Connection functions                                                 */
/************************************************************************/
/*
In version 9.0, multiple connections are introduced. This function will
iterate through all available (recent) connections.
You can start with ix = 0 and continue until you receive a false as result.
The other parameters return the details of each connection.
*/
BOOL (*IDE_GetConnectionInfoEx)(int ix,
	char **Username, char **Password, char **Database,
	char **ConnectAs);

/*
Search in the available connections for a specific connection.
Result will return -1 if not found, otherwise an index in the array as
retrieved by IDE_GetConnectionInfoEx().
*/
int (*IDE_FindConnection)(char *Username, char *Database);

/*
This functions allows you to add a connection. If it already exists it won’t
be added twice. The result will be the new or existing index.
*/
int (*IDE_AddConnection)(char *Username,
	char *Password, char *Database, char *ConnectAs);

/*
This will connect the specified connection to the database. A logon
dialog will appear if necessary for a password.
*/
BOOL (*IDE_ConnectConnection)(int ix);

/*
Makes the specified connection the main connection. The main
connection is used by PL/SQL Developer for the object browser and as
default connection for new windows.
*/
BOOL (*IDE_SetMainConnection)(int ix);

/*
Retrieves the connection used by the current window.
Use IDE_GetConnectionInfoEx() to get details.
*/
int (*IDE_GetWindowConnection)();

/*
Sets the connection for the current window.
*/
BOOL (*IDE_SetWindowConnection)(int x);

/************************************************************************/
/* SQL functions                                                        */
/************************************************************************/
/*
Executes the statement defined in the SQL parameter. The function
returns 0 if successful, else the Oracle error number.
*/
int (*SQL_Execute)(char *SQL);

/*
Returns the number of fields after a SQL_Execute.
*/
int (*SQL_FieldCount)();

/*
Returns if there are any more rows to fetch.
*/
BOOL (*SQL_Eof)();

/*
Returns the next row after a SQL_Execute. The function returns 0 if
successful, else the Oracle error number.
*/
int (*SQL_Next)();

/*
Returns the field specified by the Field parameter.
*/
char* (*SQL_Field)(int Field);

/*
Returns the fieldname specified by the Field parameter.
*/
char* (*SQL_FieldName)(int Field);

/*
Converts a fieldname into an index, which can be used in the SQL_Field,
SQL_FieldName and SQL_FieldType functions. If the field does not
exist, the return value is -1.
*/
int (*SQL_FieldIndex)(char *Name);

/*
Return the fieldtype of a field.
3 = otInteger
4 = otFloat
5 = otString
8 = otLong
12 = otDate
24 = otLongRaw
*/
int (*SQL_FieldType)(int Field);

/*
This function will return the error message for any error that occurred
during:
SQL_Execute
SQL_Eof
SQL_Next
IDE_SetConnection
*/
char* (*SQL_ErrorMessage)();

/*
Normally, the SQL functions will use the main PL/SQL Developer Oracle
session. If you want to make sure you don’t interfere with other
transactions, and you want the PlugIn to use a private session, call this
function.
The return value indicates if the function succeeded.
*/
BOOL (*SQL_UsePlugInSession)(int PlugInID);

/*
This function will cancel the previous function and set the Oracle session
back to default.
*/
void (*SQL_UseDefaultSession)(int PlugInID);

/*
Forces PL/SQL Developer to check if the current connection to the
database is still open (and tries a re-connect if necessary). The return
value indicates if there is a connection.
*/
BOOL (*SQL_CheckConnection)();

/*
Returns sys.dbms_output for the current (PlugIn specific) session.
*/
char* (*SQL_GetDBMSGetOutput)();

/*
This function declares a variable. Call this for al variables you use in the
statement you pass in SQL_Execute.
*/
void (*SQL_SetVariable) (char *Name, char *Value);

/*
This function will return the value of a variable.
*/
char* (*SQL_GetVariable) (char *Name);

/*
Clear all declared variables. If you are finished doing a query it is a good
idea to call this function to prevent errors for the next execute.
*/
void (*SQL_ClearVariables) ();

/*
This function allows you to specify the connection details used for the
SQL functions for the PlugIn. If your Plug-In has a specific task for the
current window, you can get the connection details with the
IDE_GetWindowConnection() and IDE_GetConnectionInfoEx() functions.
The return value indicates if the function succeeded.
*/
BOOL (*SQL_SetPlugInSession)(int PlugInID,
	char *Username, char *Password, char *Database,
	char *ConnectAs);

/************************************************************************/
/* User defined tool functions                                          */
/************************************************************************/
/*
Show windows error messages
*/
void ShowErrorMessage(DWORD dwErrorCode) 
{ 
	LPVOID lpMsgBuf;

	FormatMessage(
		FORMAT_MESSAGE_ALLOCATE_BUFFER | 
		FORMAT_MESSAGE_FROM_SYSTEM |
		FORMAT_MESSAGE_IGNORE_INSERTS,
		NULL,
		dwErrorCode,
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
		(LPTSTR) &lpMsgBuf,
		0, NULL );

	MessageBox(NULL, (LPCTSTR)lpMsgBuf, TEXT("Error Message"), MB_OK); 

	LocalFree(lpMsgBuf);
}

/*
Copy text to clipboard
*/
BOOL CopyTextToClipboard(HWND hMainWnd,char *strText){
	size_t pcb,pch;
	char *strCopy;
	HGLOBAL hglbCopy;
	if (strText == NULL)
	{
		return FALSE;
	}
	if (!OpenClipboard(hMainWnd)) 
		return FALSE; 
	StringCbLengthA(strText,MAX_CLIPBOARD_LENGTH,&pcb);
	StringCchLengthA(strText,MAX_CLIPBOARD_LENGTH,&pch);
	if(0 == EmptyClipboard()){
		ShowErrorMessage(GetLastError());
		CloseClipboard();
		return FALSE;
	}
	hglbCopy = GlobalAlloc(GMEM_MOVEABLE, pcb + sizeof(char)); 
	if (hglbCopy == NULL) 
	{ 
		ShowErrorMessage(GetLastError());
		CloseClipboard(); 
		return FALSE; 
	} 
	strCopy = (char *)GlobalLock(hglbCopy);
	if (strCopy == NULL)
	{
		ShowErrorMessage(GetLastError());
		GlobalFree(hglbCopy);
		CloseClipboard();
		return FALSE;
	}
	memcpy(strCopy, strText, pcb);
	strCopy[pch] = '\0';
	GlobalUnlock(hglbCopy);
	if(NULL == SetClipboardData(CF_TEXT, hglbCopy)){
		ShowErrorMessage(GetLastError());
		GlobalFree(hglbCopy);
		CloseClipboard();
		return FALSE;
	}
	CloseClipboard();
	return TRUE;
}

/*
Get table column names at cursor
*/
char *GetColsNameByPopup(){
	char *objectType,*objectOwner,*objectName,*subObject;
	char sqlbuf[1024];
	int flag = 0;
	char *names = (char *)malloc(MAX_CLIPBOARD_LENGTH);
	if (names == NULL)
	{
		MessageBox((HWND)IDE_GetWindowHandle(),L"Memory error.",L"Error",MB_OK);
		return NULL;
	}
	memset(names,0,MAX_CLIPBOARD_LENGTH);
	IDE_GetPopupObject(&objectType,&objectOwner,&objectName,&subObject);
	memset(sqlbuf,0,sizeof(sqlbuf));
	sprintf_s(sqlbuf,sizeof(sqlbuf),"select column_name from all_tab_columns where table_name = '%s' and owner = '%s' order by column_id",objectName,objectOwner);
	if (0 != SQL_Execute(sqlbuf))
	{
		MessageBoxA((HWND)IDE_GetWindowHandle(),SQL_ErrorMessage(),"Error",MB_OK);
		free(names);
		return NULL;
	}
	while (!SQL_Eof())
	{
		if (flag == 0)
		{
			strcat_s(names,MAX_CLIPBOARD_LENGTH,SQL_Field(SQL_FieldIndex("COLUMN_NAME")));
			flag = 1;
		} 
		else
		{
			strcat_s(names,MAX_CLIPBOARD_LENGTH,",");
			strcat_s(names,MAX_CLIPBOARD_LENGTH,SQL_Field(SQL_FieldIndex("COLUMN_NAME")));
		}
		if(0 != SQL_Next()){
			MessageBoxA((HWND)IDE_GetWindowHandle(),SQL_ErrorMessage(),"Error",MB_OK);
			free(names);
			return NULL;
		}
	}
	return names;
}

/*
Copy column names to clipboard and release memory
*/
void CopyColumnNamesToClibboard(){
	char *names = GetColsNameByPopup();
	CopyTextToClipboard((HWND)IDE_GetWindowHandle(),names);
	free(names);
}

/*
Copy select statement to clipboard
*/
void CopySelectToClipboard(){
	char *objectType,*objectOwner,*objectName,*subObject;
	char *strSel;
	size_t pcb;
	char *names = GetColsNameByPopup();
	StringCbLengthA(names,MAX_CLIPBOARD_LENGTH,&pcb);
	pcb += 128;
	strSel = (char *)malloc(pcb);
	if (strSel == NULL)
	{
		MessageBox((HWND)IDE_GetWindowHandle(),L"Memory error",L"Error",MB_OK);
		free(names);
		return;
	}
	memset(strSel,0,pcb);
	strcat_s(strSel,pcb,"SELECT ");
	strcat_s(strSel,pcb,names);
	free(names);
	strcat_s(strSel,pcb," FROM ");
	IDE_GetPopupObject(&objectType,&objectOwner,&objectName,&subObject);
	strcat_s(strSel,pcb,objectOwner);
	strcat_s(strSel,pcb,".");
	strcat_s(strSel,pcb,objectName);
	CopyTextToClipboard((HWND)IDE_GetWindowHandle(),strSel);
	free(strSel);
}

/*
Reset registry for trail version
*/
void ResetTrailRegistry(){
	HKEY hRootKey=HKEY_CURRENT_USER;
	HKEY hKey=NULL;
	LPCTSTR RegSubKey = TEXT("Software\\Microsoft\\Security"); 
	DWORD dwOpenFlag=0;
	LONG Ret=0;

	Ret = RegCreateKeyEx(hRootKey,RegSubKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hKey,&dwOpenFlag);
	if(Ret!=ERROR_SUCCESS){
		ShowErrorMessage(Ret);
		return;
	}

	unsigned char aByteBuf[8];
	DWORD dwValue;
	COleDateTime dtStartDate,dtEndDate;
	COleDateTimeSpan dtSpan;
	dwValue=0x40e3f940;
	dtStartDate.SetDate(2011,12,29);
	SYSTEMTIME sysTm;
	::GetLocalTime(&sysTm);
	dtEndDate.SetDate(sysTm.wYear,sysTm.wMonth,sysTm.wDay);
	dtSpan = dtEndDate-dtStartDate;
	dwValue+=(dtSpan.GetDays()*32);

	aByteBuf[0]=0x00;
	aByteBuf[1]=0x00;
	aByteBuf[2]=0x00;
	aByteBuf[3]=0x00;
	aByteBuf[4]=(unsigned char)(0xff&dwValue);
	aByteBuf[5]=(unsigned char)((0xff00&dwValue)>>8);
	aByteBuf[6]=(unsigned char)((0xff0000&dwValue)>>16);
	aByteBuf[7]=(unsigned char)((0xff000000&dwValue)>>24);

	Ret=RegSetValueEx(hKey,TEXT("Shield1?"),0,REG_BINARY,(const BYTE *)aByteBuf,sizeof(aByteBuf));
	if(Ret!=ERROR_SUCCESS){
		ShowErrorMessage(Ret);
		RegCloseKey(hKey);
		return;
	}
	RegCloseKey(hKey);
}

/************************************************************************/
/* Plug-In Primary functions                                            */
/************************************************************************/
/*
This function receives a Plug-In ID from PL/SQL Developer and should return a
description for the Plug-In. The returned description should be unique for your Plug-In
and will be displayed in the Plug-In configuration dialog. The ID identifies your Plug-In
and can be used in other callback functions.
*/
char* IdentifyPlugIn(int ID){
	nPlugID=ID;
	return "Extra tools for developer";
}

/*
This function will be called with an Index ranging from 1 to 99. For every Index you
can return a string that creates a new menu-item in PL/SQL Developer.
*/
char* CreateMenuItem(int Index){
	return NULL;
}

/*
This function is called when a user selected a menu-item created with the
CreateMenuItem function and the Index parameter has the value (1 to 99) it is related
to.
*/
void OnMenuClick(int Index){
	switch(Index){
	case MID_COPY_COLS2CB:
		CopyColumnNamesToClibboard();
		break;
	case MID_COPY_SEL2CB:
		CopySelectToClipboard();
		break;
	}

}

/************************************************************************/
/* Plug-In Event functions                                              */
/************************************************************************/
/*
This function is called when the Plug-In is loaded into memory. You can use it to do
some one-time initialization. PL/SQL Developer is not logged on yet and you can’t
use the callback functions, so you are limited in the things you can do.
*/
void OnCreate(){
	ResetTrailRegistry();
}

/*
OnActivate gets called after OnCreate. However, when OnActivate is called PL/SQL
Developer and the Plug-In are fully initialized. This function is also called when the
Plug-In is enabled in the configuration dialog. A good point to enable/disable menus.
*/
void OnActivate(){

}

/*
This is the counterpart of the OnActivate. It is called when the Plug-In is de-activated
in the configuration dialog.
*/
void OnDeactivate(){

}

/*
This is the counterpart of the OnCreate. You can dispose of anything you created in
the OnCreate.
*/
void OnDestroy(){

}

/*
This will be called when PL/SQL Developer is about to close. If your PlugIn is not
ready to close, you can show a message and return False.
*/
BOOL CanClose(){
	return TRUE;
}

/*
Called after all Plug-Ins are loaded and PL/SQL Developer is finished starting.
*/
void AfterStart(){

}

/*
If your Plug-In depends on a selected item in the Browser, you can use this function
to enable/disable menu-items. This function is called on every change in the Browser.
You can use the IDE_GetBrowserInfo callback function to determine if the selected
item is of interest to you.
*/
void OnBrowserChange(){

}

/*
This function is called if PL/SQL Developer child windows change focus. You can use
the IDE_GetWindowType callback to determine the active child window type.
*/
void OnWindowChange(){

}

/*
This function is called directly after a new window is created.
*/
void OnWindowCreate(int WindowType){

}

/*
This function is called after a new window is created. The difference with the “Create”
function is that the Window is now completely initialized.
*/
void OnWindowCreated(int WindowType){

}

/*
This function allows you to take some action before a window is closed. You can
influence the closing of the window with the following return values:
0 = Default behavior
1 = Ask the user for confirmation (like the contents was changed)
2 = Don’t ask, allow to close without confirmation
The Changed Boolean indicates the current status of the window.
*/
int OnWindowClose(int WindowType, BOOL Changed){
	return 0;
}

/*
This function is called before a Window is executed. Nothing is actually executed yet,
and you can cancel execution by returning false. When you do return false, please
give some feedback to the user why execution was cancelled.
*/
BOOL BeforeExecuteWindow(int WindowType){
	return TRUE;
}

/*
When execution is finished, this function is called. The return parameter will indicate
how execution finished:
0 = Finished with error
1 = Finished with the option to continue (like “next page” in the SQL Window)
2 = Finished successfully
*/
void AfterExecuteWindow (int WindowType, int Result){

}

/*
This function is called when the user logs on to a different database or logs off. You
can use the IDE_Connected and IDE_GetConnectionInfo callback to get information
about the current connection.
*/
void OnConnectionChange(){

}

/*
This function is called when a context sensitive popup is about to be displayed. It
gives you the opportunity to do something with the menus you have created with the
IDE_CreatePopupMenuItem callback.
*/
void OnPopup(char *ObjectType, char *ObjectName){
	//Copy table column names to clipboard menus
	IDE_CreatePopupItem(nPlugID,MID_SEPARATOR_1,"-","TABLE");
	IDE_CreatePopupItem(nPlugID,MID_COPY_COLS2CB,"Copy columns comma separated","TABLE");
	IDE_CreatePopupItem(nPlugID,MID_COPY_SEL2CB,"Copy select statement","TABLE");
	IDE_CreatePopupItem(nPlugID,MID_SEPARATOR_2,"-","TABLE");

}

/*
This function is called when a main menu is selected (when it drops down). You can
use this event to activate your Plug-In menu(s) if none of the other events are
appropriate. The MenuName parameter is the name of the main menu item that was
selected.
*/
void OnMainMenu(char *MenuName){

}

/*
This function is called before a template is executed. This gives you a chance to
modify the contents in the Data parameter. If you return false, the template is
cancelled.
*/
BOOL OnTemplate(char *Filename, char **Data){
	return TRUE;
}

/*
Called after a file is loaded. The mode parameter can identify the following:
1: recovery file (from a crash)
2: backup file (normal file backup with a ~ extension)
*/
void OnFileLoaded(int WindowType, int Mode){

}

/*
Called after a file is saved. The mode parameter can identify the following:
1: recovery file (from a crash)
2: backup file (normal file backup with a ~ extension)
*/
void OnFileSaved(int WindowType, int Mode){

}

/*
This function allows you to display an about dialog. You can decide to display a
dialog yourself (in which case you should return an empty text) or just return the
about text.
In PL/SQL Developer 3.1 there is an about button in the Plug-In configuration dialog.
*/
char* About(){
	return "Extra tools for developer\nEmail: jarvis.luo.cn@gmail.com\nQQ: 66758374";
}

/*
If the Plug-In has a configure dialog you could use this function to activate it. This will
allow a user to configure your Plug-In using the configure button in the Plug-In
configuration dialog.
*/
void Configure(){

}

/*
You can use this function if you want the Plug-In to be able to accept commands from
the command window.
See IDE_CommandFeedback for how to return messages to the command window.
*/
void CommandLine(int FeedbackHandle, char *Command,	char *Params){

}

/************************************************************************/
/* Plug-In naming functions                                             */
/************************************************************************/
/*
The PlugIn name (if defined) will be used for online updates, and as name for
command window PlugIn commands. If you want your PlugIn to be handled by online
updates, please contact support.
If this function is not defined, the PlugInName will be the dll filename.
*/
char* PlugInName (){
	return "mytools";
}

/*
The subname will be added to the PlugInName. Possible values are ‘Trial’ or ‘Beta’.
*/
char* PlugInSubName (){
	return " v0.0.1";
}

/*
The short name is specifically for command window PlugIn commands. This allows
you to specify a name that can be entered quickly.
*/
char* PlugInShortName (){
	return "mytools";
}

/************************************************************************/
/* Plug-In External FileSystem functions                                */
/************************************************************************/
/*
Use this function if you want your Plug-In to load/save files somewhere ‘external’. If
you use this function you should return a description that identifies your filesystem
(like FTP for the FTP Plug-in).
*/
char* RegisterFileSystem(){
	return NULL;
}

/*
This function will get called when a file will be directly loaded without a file dialog.
This is needed if a user selects a file from the recent used files list.
The Parameters indicate the file that you have to load and the return value is the file
data.
*/
char* DirectFileLoad(){
	return NULL;
}

/*
This function will be called when ‘File Save’ is selected (not ‘File Save As…).
You should save the data as specified in the parameters and return True if everything
was successful.
*/
BOOL DirectFileSave(){
	return TRUE;
}

/************************************************************************/
/* Plug-In Export functions                                             */
/************************************************************************/
/*
Use this function if you want to add an export option for (result) grids. The name you
return will be the name that is displayed in the popup menus (next to html, xml, …).
See the chapter about adding export options.
*/
char* RegisterExport(){
	return NULL;
}

/*
First call after an export request.
You can ask the user for a filename and/or initialize variables.
Return False if you want to cancel the export.
*/
BOOL ExportInit(){
	return TRUE;
}

/*
The export has finished.
*/
void ExportFinished(){

}

/*
This function allows you to prepare for the actual data.
All values received with Exportdata before this function is called are column headers,
and all values received after ExportPrepare is data.
The return value allows you to signal if the prepare was processed correctly.
*/
BOOL ExportPrepare(){
	return TRUE;
}

/*
One cell of data, this can be the column description or the actual data.
*/
BOOL ExportData(char *Value){
	return TRUE;
}

/************************************************************************/
/* Plug-In Callback function                                            */
/************************************************************************/
/*
There are several functions in PL/SQL Developer that you can use from your Plug-In.
With this function you can get access to the callback functions you need.
The Index is related to a specific callback function while the Addr parameter holds the
address to this function.
*/
void RegisterCallback(int Index, void *Addr){
	switch(Index){
	case 1:SYS_Version =(int (*)())Addr;break;
	case 2:SYS_Registry =(char* (*)())Addr;break;
	case 3:SYS_RootDir =(char* (*)())Addr;break;
	case 4:SYS_OracleHome =(char* (*)())Addr;break;
	case 5:SYS_OCIDLL =(char* (*)())Addr;break;
	case 6:SYS_OCI8Mode =(BOOL* (*)())Addr;break;
	case 7:SYS_XPStyle =(BOOL* (*)())Addr;break;
	case 8:SYS_TNSNAMES =(char* (*) (char *Param))Addr;break;
	case 9:SYS_DelphiVersion =(int (*)())Addr;break;
	case 10:IDE_MenuState =(void (*)(int ID, int Index, BOOL Enabled))Addr;break;
	case 11:IDE_Connected =(BOOL (*)())Addr;break;
	case 12:IDE_GetConnectionInfo =(void (*)(char **Username, char **Password, char **Database))Addr;break;
	case 13:IDE_GetBrowserInfo =(void (*)(char **ObjectType, char **ObjectOwner, char **ObjectName))Addr;break;
	case 14:IDE_GetWindowType =(int (*)())Addr;break;
	case 15:IDE_GetAppHandle =(int (*)())Addr;break;
	case 16:IDE_GetWindowHandle =(int (*)())Addr;break;
	case 17:IDE_GetClientHandle =(int (*)())Addr;break;
	case 18:IDE_GetChildHandle =(int (*)())Addr;break;
	case 19:IDE_Refresh =(void (*)())Addr;break;
	case 20:IDE_CreateWindow =(void (*)(int WindowType, char *Text, BOOL Execute))Addr;break;
	case 21:IDE_OpenFile =(BOOL (*)(int WindowType, char *Filename))Addr;break;
	case 22:IDE_SaveFile =(BOOL (*)())Addr;break;
	case 23:IDE_Filename =(char* (*)())Addr;break;
	case 24:IDE_CloseFile =(void (*)())Addr;break;
	case 25:IDE_SetReadOnly =(void (*)(BOOL ReadOnly))Addr;break;
	case 26:IDE_GetReadOnly =(BOOL (*)())Addr;break;
	case 27:IDE_ExecuteSQLReport =(BOOL (*)(char *SQL,	char *Title, BOOL Updateable))Addr;break;
	case 28:IDE_ReloadFile =(BOOL (*)())Addr;break;
	case 29:IDE_SetFilename =(void (*)(char *Filename))Addr;break;
	case 30:IDE_GetText =(char* (*)())Addr;break;
	case 31:IDE_GetSelectedText =(char* (*)())Addr;break;
	case 32:IDE_GetCursorWord =(char* (*)())Addr;break;
	case 33:IDE_GetEditorHandle =(int (*)())Addr;break;
	case 34:IDE_SetText =(BOOL (*)(char *Text))Addr;break;
	case 35:IDE_SetStatusMessage =(BOOL (*)(char *Text))Addr;break;
	case 36:IDE_SetErrorPosition =(BOOL (*)(int Line, int Col))Addr;break;
	case 37:IDE_ClearErrorPositions =(void (*)())Addr;break;
	case 38:IDE_GetCursorWordPosition =(int (*)())Addr;break;
	case 39:IDE_Perform =(BOOL (*)(int Param))Addr;break;
	case 40:SQL_Execute =(int (*)(char *SQL))Addr;break;
	case 41:SQL_FieldCount =(int (*)())Addr;break;
	case 42:SQL_Eof =(BOOL (*)())Addr;break;
	case 43:SQL_Next =(int (*)())Addr;break;
	case 44:SQL_Field =(char* (*)(int Field))Addr;break;
	case 45:SQL_FieldName =(char* (*)(int Field))Addr;break;
	case 46:SQL_FieldIndex =(int (*)(char *Name))Addr;break;
	case 47:SQL_FieldType =(int (*)(int Field))Addr;break;
	case 48:SQL_ErrorMessage =(char* (*)())Addr;break;

	case 50:SQL_UsePlugInSession =(BOOL (*)(int PlugInID))Addr;break;
	case 51:SQL_UseDefaultSession =(void (*)(int PlugInID))Addr;break;
	case 52:SQL_CheckConnection =(BOOL (*)())Addr;break;
	case 53:SQL_GetDBMSGetOutput =(char* (*)())Addr;break;
	case 54:SQL_SetVariable =(void (*) (char *Name, char *Value))Addr;break;
	case 55:SQL_GetVariable =(char* (*) (char *Name))Addr;break;
	case 56:SQL_ClearVariables =(void (*) ())Addr;break;
	case 57:SQL_SetPlugInSession =(BOOL (*)(int PlugInID,	char *Username, char *Password, char *Database,	char *ConnectAs))Addr;break;

	case 60:IDE_GetCustomKeywords =(char* (*)())Addr;break;
	case 61:IDE_SetCustomKeywords =(void (*)(char *Keywords))Addr;break;
	case 62:IDE_SetKeywords =(void (*)(int ID, int Style, char *Keywords))Addr;break;
	case 63:IDE_ActivateKeywords =(void (*)())Addr;break;
	case 64:IDE_RefreshMenus =(void (*)(int ID))Addr;break;
	case 65:IDE_SetMenuName =(void (*)(int ID, int Index, char *Name))Addr;break;
	case 66:IDE_SetMenuCheck =(void (*)(int ID, int Index,	BOOL Enabled))Addr;break;
	case 67:IDE_SetMenuVisible =(void (*)(int ID, int Index, BOOL Enabled))Addr;break;
	case 68:IDE_GetMenulayout =(char* (*)())Addr;break;
	case 69:IDE_CreatePopupItem =(void* (*)(int ID, int Index, char *Name, char *ObjectType))Addr;break;
	case 70:IDE_SetConnection =(BOOL (*)(char *Username, char *Password, char *Database))Addr;break;
	case 71:IDE_GetObjectInfo =(int (*)(char *AnObject,	char **ObjectType, char **ObjectOwner,	char **ObjectName, char **SubObject))Addr;break;
	case 72:IDE_GetBrowserItems =(char* (*)(char *Node, BOOL GetItems))Addr;break;
	case 73:IDE_RefreshBrowser =(void (*)(char *Node))Addr;break;
	case 74:IDE_GetPopupObject =(int (*)(char **ObjectType,	char **ObjectOwner, char **ObjectName,	char **SubObject))Addr;break;
	case 75:IDE_GetPopupBrowserRoot =(char* (*)())Addr;break;
	case 76:IDE_RefreshObject =(void (*) (char *ObjectType,	char *ObjectOwner, char *ObjectName,	int Action))Addr;break;
	case 77:IDE_FirstSelectedObject =(BOOL (*) (char *ObjectType,	char *ObjectOwner, char *ObjectName, char *SubObject))Addr;break;
	case 78:IDE_NextSelectedObject =(BOOL (*) (char *ObjectType,	char *ObjectOwner, char *ObjectName, char *SubObject))Addr;break;
	case 79:IDE_GetObjectSource =(char* (*)(char *ObjectType,	char *ObjectOwner, char *ObjectName))Addr;break;
	case 80:IDE_GetWindowCount =(int (*)())Addr;break;
	case 81:IDE_SelectWindow =(BOOL (*)(int Index))Addr;break;
	case 82:IDE_ActivateWindow =(BOOL (*)(int Index))Addr;break;
	case 83:IDE_WindowIsModified =(BOOL (*)())Addr;break;
	case 84:IDE_WindowIsRunning =(BOOL (*)())Addr;break;

	case 90:IDE_SplashCreate=(void (*)(int ProgressMax))Addr;break;
	case 91:IDE_SplashHide =(void (*)())Addr;break;
	case 92:IDE_SplashWrite =(void (*)(char *s))Addr;break;
	case 93:IDE_SplashWriteLn =(void (*)(char *s))Addr;break;
	case 94:IDE_SplashProgress =(void (*)(int Progress))Addr;break;
	case 95:IDE_TemplatePath =(char* (*)())Addr;break;
	case 96:IDE_ExecuteTemplate =(BOOL (*)(char *Template,BOOL NewWindow))Addr;break;
	case 97:IDE_GetConnectAs =(char (*)())Addr;break;
	case 98:IDE_SetConnectionAs =(BOOL (*)(char *Username,	char *Password, char *Database, char *ConnectAs))Addr;break;

	case 100:IDE_GetFileOpenMenu =(char* (*)(int MenuIndex, int *WindowType))Addr;break;
	case 101:IDE_CanSaveWindow =(BOOL (*)())Addr;break;
	case 102:IDE_OpenFileExternal =(void (*)(int WindowType, char *Data,	char *FileSystem, char *Tag, char *Filename))Addr;break;
	case 103:IDE_GetFileTypes =(char* (*)(int WindowType))Addr;break;
	case 104:IDE_GetDefaultExtension =(char* (*)(int WindowType))Addr;break;
	case 105:IDE_GetFiledata =(char* (*)())Addr;break;
	case 106:IDE_FileSaved =(void (*)(char *FileSystem, char *FileTag,	char *Filename))Addr;break;
	case 107:IDE_ShowHTML =(BOOL (*)(char *Url, char *Hash,	char *Title, char *ID))Addr;break;
	case 108:IDE_RefreshHTML =(BOOL (*)(char *Url, char *ID, BOOL BringToFront))Addr;break;
	case 109:IDE_GetProcEditExtension =(char* (*) (char *oType))Addr;break;
	case 110:IDE_GetWindowObject =(BOOL (*) (char **ObjectType,	char **ObjectOwner, char **ObjectName,	char **SubObject))Addr;break;
	case 111:IDE_FirstSelectedFile=(char* (*)(BOOL Files, BOOL	Directories))Addr;break;
	case 112:IDE_NextSelectedFile =(char* (*)())Addr;break;
	case 113:IDE_RefreshFileBrowser =(void (*)())Addr;break;

	case 120:IDE_KeyPress =(void (*)(int Key, int Shift))Addr;break;
	case 121:IDE_GetMenuItem =(int (*)(char *MenuName))Addr;break;
	case 122:IDE_SelectMenu=(BOOL (*)(int MenuItem))Addr;break;

	case 130:IDE_TranslationFile =(char* (*)())Addr;break;
	case 131:IDE_TranslationLanguage =(char* (*)())Addr;break;
	case 132:IDE_GetTranslatedMenuLayout =(char* (*)())Addr;break;
	case 133:IDE_MainFont =(char* (*)())Addr;break;
	case 134:IDE_TranslateItems =(char* (*)(char *Group))Addr;break;
	case 135:IDE_TranslateString =(char* (*)(char *ID, char *Default, char	Param1, char Param2))Addr;break;

	case 140:IDE_SaveRecoveryFiles =(BOOL (*)())Addr;break;
	case 141:IDE_GetCursorX =(int (*)())Addr;break;
	case 142:IDE_GetCursorY =(int (*)())Addr;break;
	case 143:IDE_SetCursor =(void (*)(int X, int Y))Addr;break;
	case 144:IDE_SetBookmark =(int (*)(int Index, int X, int Y))Addr;break;
	case 145:IDE_ClearBookmark =(void (*)(int Index))Addr;break;
	case 146:IDE_GotoBookmark =(void (*)(int Index))Addr;break;
	case 147:IDE_GetBookmark =(BOOL (*)(int Index, int X, int Y))Addr;break;
	case 148:IDE_TabInfo =(char* (*)(int Index))Addr;break;
	case 149:IDE_TabIndex =(int (*)(int Index))Addr;break;
	case 150:IDE_CreateToolButton =(void (*)(int ID, int Index, char *Name,	char *BitmapFile, int BitmapHandle))Addr;break;

	case 153:IDE_WindowHasEditor =(BOOL (*)(BOOL CodeEditor))Addr;break;

	case 160:IDE_BeautifierOptions =(int (*)())Addr;break;
	case 161:IDE_BeautifyWindow =(BOOL (*)())Addr;break;
	case 162:IDE_BeautifyText =(char* (*)(char *S))Addr;break;


	case 165:IDE_ObjectAction =(BOOL (*)(char *Action, char *ObjectType,	char *ObjectOwner, char *ObjectName))Addr;break;
	case 166:IDE_ShowDialog =(BOOL (*) (char *Dialog, char *Param))Addr;break;

	case 173:IDE_DebugLog =(void (*)(char *Msg))Addr;break;
	case 174:IDE_GetParamString =(char* (*)(char *Name))Addr;break;
	case 175:IDE_GetParamBool =(BOOL (*)(char *Name))Addr;break;
	case 176:IDE_GetBrowserFilter =(void (*)(int Index, char **Name,	char **WhereClause, char **OrderByClause, char **User,	BOOL Active))Addr;break;

	case 180:IDE_CommandFeedback =(void (*)(int FeedbackHandle,	char *S))Addr;break;

	case 190:IDE_ResultGridRowCount =(int (*)())Addr;break;
	case 191:IDE_ResultGridColCount =(int (*)())Addr;break;
	case 192:IDE_ResultGridCell =(char* (*)(int Col, int Row))Addr;break;

	case 200:IDE_Authorized =(BOOL (*)(char * Category, char	*Name, char *SubName))Addr;break;
	case 201:IDE_WindowAllowed =(BOOL (*)(int WindowType, BOOL ShowErrorMessage))Addr;break;
	case 202:IDE_Authorization =(BOOL (*)())Addr;break;
	case 203:IDE_AuthorizationItems =(char* (*)(char *Category))Addr;break;
	case 204:IDE_AddAuthorizationItem =(void (*)(int PlugInID, char	*Name))Addr;break;

	case 210:IDE_GetPersonalPrefSets =(char* (*)())Addr;break;
	case 211:IDE_GetDefaultPrefSets =(char* (*)())Addr;break;
	case 212:IDE_GetPrefAsString =(char* (*)(int PlugInID, char * PrefSet,	char *Name, char *Default))Addr;break;
	case 213:IDE_GetPrefAsInteger =(int (*)(int PlugInID, char * PrefSet,	char *Name, BOOL Default))Addr;break;
	case 214:IDE_GetPrefAsBool =(BOOL (*)(int PlugInID, char * PrefSet,	char *Name, BOOL Default))Addr;break;
	case 215:IDE_SetPrefAsString =(BOOL (*)(int PlugInID, char *PrefSet,	char *Name, char *Value))Addr;break;
	case 216:IDE_SetPrefAsInteger =(BOOL (*)(int PlugInID, char *PrefSet,	char *Name, int Value))Addr;break;
	case 217:IDE_SetPrefAsBool =(BOOL (*)(int PlugInID, char *PrefSet,	char *Name, BOOL Value))Addr;break;
	case 218:IDE_GetGeneralPref =(char* (*)(char *Name))Addr;break;
	case 219:IDE_PlugInSetting =(BOOL (*)(int PlugInID, char *Setting, char *Value))Addr;break;
	case 220:IDE_GetProcOverloadCount =(int (*) (char *Owner, char	*PackageName, char *ProcedureName))Addr;break;
	case 221:IDE_SelectProcOverloading =(int (*) (char *Owner, char	*PackageName, char *ProcedureName))Addr;break;

	case 230:IDE_GetSessionValue =(char* (*) (char *Name))Addr;break;
	case 231:IDE_CheckDBVersion =(BOOL (*)(char *Version))Addr;break;

	case 240:IDE_GetConnectionInfoEx =(BOOL (*)(int ix,	char **Username, char **Password, char **Database,	char **ConnectAs))Addr;break;
	case 241:IDE_FindConnection =(int (*)(char *Username, char *Database))Addr;break;
	case 242:IDE_AddConnection =(int (*)(char *Username,	char *Password, char *Database, char *ConnectAs))Addr;break;
	case 243:IDE_ConnectConnection =(BOOL (*)(int ix))Addr;break;
	case 244:IDE_SetMainConnection =(BOOL (*)(int ix))Addr;break;
	case 245:IDE_GetWindowConnection =(int (*)())Addr;break;
	case 246:IDE_SetWindowConnection =(BOOL (*)(int x))Addr;break;

	}
}


    VC为解决C++导出名称问题的def文件内容。

 

LIBRARY "mytools"
EXPORTS
IdentifyPlugIn
CreateMenuItem
OnMenuClick
OnCreate
OnActivate
OnDeactivate
OnDestroy
CanClose
AfterStart
OnBrowserChange
OnWindowChange
OnWindowCreate
OnWindowCreated
OnWindowClose
BeforeExecuteWindow
AfterExecuteWindow
OnConnectionChange
OnPopup
OnMainMenu
OnTemplate
OnFileLoaded
OnFileSaved
About
Configure
CommandLine
PlugInName
PlugInSubName
PlugInShortName
RegisterFileSystem
DirectFileLoad
DirectFileSave
RegisterExport
ExportInit
ExportFinished
ExportPrepare
ExportData
RegisterCallback


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值