tailieunhanh - Financial Applications Using Excel Add-in Development in C/C++Second Edition phần 6

Đây là một vấn đề mà đặc biệt là ảnh hưởng đến các add-in trong Excel 2007 tính toán lại bảng tính đa luồng có thể. Sau đó bộ phận nàyTạo một 32-bit Windows (Win32) DLL Sử dụng Visual C + + hay Visual Studio. NET | Accessing Excel Functionality Using the C API 265 xltypeNil These depend on the the version and what is provided char types code_name arg_names if gExcelVersion12plus if ps- name_in_code12 ps- name_in_code12 0 code_name ps- name_in_code12 types ps- types12 else code_name ps- name_in_code types ps- types if ps- arg_names12 ps- arg_names12 0 arg_names ps- arg_names12 else arg_names ps- arg_names else code_name ps- name_in_code types ps- types arg_names ps- arg_names if check_register_args ps- ws_name types arg_names return false int arg_limit gExcelVersion12plus MAX_XL12_UDF_ARGS MAX_XL11_UDF_ARGS Array of pointers to xloper that will be passed to Excel4v const cpp_xloper ptr_array MAX_XL12_UDF_ARGS cpp_xloper FnArgs MAX_XL12_UDF_ARGS Get the full path and name of the DLL. Passed as the first argument to xlfRegister. if FnArgs 0 .Excel xlGetName cpp_xloper ErrMsg Could not get XLL path name 3 Error alert type return false FnArgs 1 code_name FnArgs 2 types FnArgs 3 ps- ws_name FnArgs 4 arg_names FnArgs 5 1 FnArgs 6 ps- fn_category FnArgs 7 .SetType xltypeMissing Short cut text character FnArgs 8 ps- help_file FnArgs 9 ps- fn_description char p_arg 266 Excel Add-in Development in C C for int i 10 i arg_limit i p_arg ps- arg_help i-10 if p_arg p_arg break that was the last of the arguments for this fn Set the corresponding xlfRegister argument FnArgs i p_arg convert the string to a cpp_xloper Set up the array of pointers for int num_args i --i 0 ptr_array i FnArgs i if xlfRegister num_args ptr_array xlretSuccess cpp_xloper ErrMsg Couldn t register ErrMsg FnArgs 3 3 Error alert dialog type return false return true Note that the return value in this case is passed back via the cpp_xloper argument RetVal rather than on the stack as in the example in the previous section. A class based approach to managing registration data It is also possible to define a class which can be instantiated right next to the function