zoukankan      html  css  js  c++  java
  • MaxSDK中卸载插件的方法

    autodesk在Max2012SDK文档中否决了卸载插件这一行为,认为他不够安全,容易导致软件崩溃,确实,如果已经存在依赖关系,然后卸载了这个库,会导致问题。不过这里只是自娱自乐的探索:)。下面的代码是写了一个MaxScript的函数来实现卸载插件以及列出当前插件的文件名。

    需要说明一下的是 14000 是定义在pluginapi.h中的一个宏 MAX_RELEASE_R14 的值,也就是Max2012版本的版本号。

    MaxSDK卸载DLL
    def_visible_primitive(UnLoadPlugin, "UnLoadPlugin");

    #if MAX_RELEASE < 14000
    Value
    * UnLoadPlugin_cf(Value** arg_list, int count)
    {
    check_arg_count(
    "UnLoadPlugin", 1, count);
    TSTR inputDllName(arg_list[
    0]->to_string());
    inputDllName.toUpper();
    DllDir
    * theDllDir;
    theDllDir
    = GetCOREInterface()->GetDllDirectory();

    Value
    * result = &false_value;

    for (int i = 0; i < theDllDir->Count(); ++i)
    {
    DllDesc
    * dll_desc = &(*theDllDir)[i];
    if (dll_desc->loaded == true)
    {
    TSTR currentDllName
    = dll_desc->fname;
    currentDllName.toUpper();
    if (currentDllName == inputDllName)
    {
    for (int i = 0; i < dll_desc->NumberOfClasses(); ++i)
    {
    ClassDesc
    *class_desc = (*dll_desc)[i];
    GetCOREInterface()
    ->DeleteClass(class_desc);
    }
    dll_desc
    ->Free();
    dll_desc
    ->loaded = false;
    result
    = &true_value;
    }
    }
    }
    return result;
    }

    #else

    Value
    * UnLoadPlugin_cf(Value** arg_list, int count)
    {
    check_arg_count(
    "UnLoadPlugin", 1, count);
    TSTR inputDllName(arg_list[
    0]->to_string());
    inputDllName.toUpper();
    DllDir
    * theDllDir;
    theDllDir
    = GetCOREInterface()->GetDllDirectory();

    Value
    * result = &false_value;

    for (int i = 0; i < theDllDir->Count(); ++i)
    {
    const DllDesc * dll_desc(&(*theDllDir)[i]);
    if (dll_desc->IsLoaded() == true)
    {
    TSTR currentDllName
    = dll_desc->GetFileName();
    currentDllName.toUpper();
    if (currentDllName == inputDllName && dll_desc->GetHandle() != 0)
    {
    for (int i = 0; i < dll_desc->NumberOfClasses(); ++i)
    {
    ClassDesc
    * class_desc = (*dll_desc)[i];
    GetCOREInterface()
    ->DeleteClass(class_desc);
    }
    result
    = &true_value;
    FreeLibrary(dll_desc
    ->GetHandle());
    }
    }
    }

    return result;
    }

    #endif

    def_visible_primitive(GetPluginList,
    "GetPluginList");
    #if MAX_RELEASE < 14000
    Value
    * GetPluginList_cf(Value** arg_list, int count)
    {
    check_arg_count(
    "GetPluginList",0, count);

    one_typed_value_local(Array
    * rArray);
    vl.rArray
    = new Array (0);

    DllDir
    * theDllDir;
    theDllDir
    = GetCOREInterface()->GetDllDirectory();

    for (int i = 0; i < theDllDir->Count(); ++i)
    {
    DllDesc dll_desc
    = (*theDllDir)[i];
    if (dll_desc.loaded )
    {
    Value
    * tempName = new String(dll_desc.fname);
    vl.rArray
    ->append(tempName);
    }
    }
    return_value(vl.rArray);
    }
    #else

    Value
    * GetPluginList_cf(Value** arg_list, int count)
    {
    check_arg_count(
    "GetPluginList",0, count);

    one_typed_value_local(Array
    * rArray);
    vl.rArray
    = new Array (0);

    DllDir
    * theDllDir;
    theDllDir
    = GetCOREInterface()->GetDllDirectory();

    for (int i = 0; i < theDllDir->Count(); ++i)
    {
    const DllDesc * dll_desc(&(*theDllDir)[i]);
    if (dll_desc->IsLoaded() == true)
    {
    Value
    * tempName = new String(dll_desc->GetFileName());
    vl.rArray
    ->append(tempName);
    }
    }
    return_value(vl.rArray);
    }

    #endif

      

  • 相关阅读:
    [开源]用MQL4实现MD5加密
    如何转换WMV到MP3,WMV到MP3播放器
    C# Winform TreeView 的一些基本用法
    WinServer 2008 远程桌面连接设置
    存储数据类型的转化总结
    EF中执行sql语句,以及事务
    C#(委托a)
    LINQ绑定List到GridView
    循环遍历DataTable绑定到Table
    要将 ASP.NET 访问权限授予某个文件,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。
  • 原文地址:https://www.cnblogs.com/sitt/p/2152305.html
Copyright © 2011-2022 走看看