【UG\NX二次开发】UF 加载与卸载目标dll(UF_load_library、UF_unload_library)

/*加载dll和卸载dll*/
void dll_call_dll(char dll_path[255])
{
    UF_initialize();
    typedef void(*load_ufusr_f_p_t)(char* param, int* retcode, int paramLen);
    load_ufusr_f_p_t load_ufusr_ptr = NULL;
    int rc = UF_CALL(UF_load_library(dll_path, "ufusr", (UF_load_f_p_t*)&load_ufusr_ptr));
    if (load_ufusr_ptr != NULL)
    {
        int retcode;
        load_ufusr_ptr(dll_path, &retcode, 1);
        UF_unload_library(dll_path);
    }
    return;
}


int main()
{
    if (block  == button01)
    {
        int is_exist = 1;
        string m_Sc_Path = "D:\\temp\\a.dll";
        UF_CFI_ask_file_exist(m_Sc_Path.c_str(), &is_exist);
        if (is_exist == 0)
        {
           dll_call_dll((char *)m_Sc_Path.c_str());
        }
    }
}

你可能感兴趣的:(NX二次开发专栏,NX二次开发)