代码之家  ›  专栏  ›  技术社区  ›  Joshua Enfield Daij-Djan

构建与Dreamweaver兼容的C dll

  •  0
  • Joshua Enfield Daij-Djan  · 技术社区  · 16 年前

    我所引用的文档就在这里,而且相当简短: http://livedocs.adobe.com/en_US/Dreamweaver/9.0_API/help.html?content=dwr_sourcecontrol_so_01.html

    我遇到的问题是,我不知道如何编译实际的dll。AdobeExtensionForums上的最后一个回复是3个月前的,我不知道该怎么回答这个问题。

    令我困惑的编程部分是,我必须用C++构建DLL,但大多数教程都是基于构建目标应用程序包含的头文件来工作的。(我对动态链接库编程较新。)Dreamweaver只需要一个动态链接库,它已经知道它将调用什么。我对如何将这些信息单独放到dll文件中感到困惑,尽管基于我已经阅读的教程,因为应用程序似乎也需要头文件或lib文件。

    在我第一次尝试时,我使用了VS2008并为我的项目类型选择了win32 dll,然后在它生成的导出函数文件中添加了所需的函数。我的第一个是:

    extern "C" __declspec(dllexport) bool SCS_Connect(void **connectionData, const char siteName[64])
    {
     return true;
    }
    

    有人能帮助澄清这可能是如何工作的吗?

    编辑: 重读文件时,我注意到上面写着:

    Dreamweaver确定哪些功能 库通过调用 每个API的getProcAddress()。 功能。如果地址没有 存在,Dreamweaver假设库 不支持API。如果 地址存在,Dreamweaver使用 函数的库版本 支持功能。

    尽管我仍然不确定这对于编译DLL意味着什么。

    编辑2: 依赖关系Walker返回:

    LoadLibraryW("c:\program files\adobe\adobe dreamweaver cs3\Configuration\SourceControl\mercFlow.dll") returned 0x05110000.
    GetProcAddress(0x05110000 [MERCFLOW.DLL], "MM_InitWrapper") called from "DREAMWEAVER.EXE" at address 0x00D73D4B and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x05110000 [MERCFLOW.DLL], "SCS_GetAgentInfo") called from "DREAMWEAVER.EXE" at address 0x00D73D66 and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x05110000 [MERCFLOW.DLL], "SCS_GetNumNewFeatures") called from "DREAMWEAVER.EXE" at address 0x00D73D72 and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x05110000 [MERCFLOW.DLL], "SCS_GetNewFeatures") called from "DREAMWEAVER.EXE" at address 0x00D73D7E and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x05110000 [MERCFLOW.DLL], "SCS_Connect") called from "DREAMWEAVER.EXE" at address 0x00D73E2B and returned NULL. Error: The specified procedure could not be found (127).
    

    其中有一些是在我的DLL中定义的(一些是根据文档可选的),但没有找到。这是否意味着我的函数没有被导出?

    这是我的DLL源:

    DLL报头

    #ifndef DLLHEADER_H_INCLUDED
    #define DLLHEADER_H_INCLUDED
    #ifdef DLL_EXPORT
    # define EXPORT extern "C" __declspec (dllexport)
    #else
    # define EXPORT
    #endif
    DLL_EXPORT struct itemInfo;
    DLL_EXPORT bool SCS_GetAgentInfo(char name[32],char version[32], char description[256], const char * dwAppVersion);
    DLL_EXPORT bool SCS_Connect(void **connectionData, const char siteName[64]);
    DLL_EXPORT bool SCS_Disconnect(void *connectionData);
    DLL_EXPORT bool SCS_IsConnected(void *connectionData);
    DLL_EXPORT int SCS_GetRootFolder_Length(void *connectionData);
    DLL_EXPORT int SCS_GetFolderListLength(void *connectionData, const char *remotePath);
    DLL_EXPORT bool SCS_GetFolderList(void *connectionData, const char *remotePath, itemInfo itemList[ ], const int numItems);
    DLL_EXPORT bool SCS_Get(void *connectionData, const char *remotePathList[], const char *localPathList[], const int numItems);
    DLL_EXPORT bool SCS_Put(void *connectionData, const char *localPathList[], const char *remotePathList[], const int numItems);
    DLL_EXPORT bool SCS_NewFolder(void *connectionData,const char *remotePath);
    DLL_EXPORT bool SCS_Delete(void *connectionData, const char *remotePathList[],const int numItems);
    DLL_EXPORT bool SCS_Rename(void *connectionData, const char * oldRemotePath, const char*newRemotePath);
    DLL_EXPORT bool SCS_ItemExists(void *connectionData,const char *remotePath);
    #endif
    

    主CPP

    #define DLL_EXPORT
    #include "dllheader.h"
    #include <iostream>
    char* const gName="MercFlow";
    char* const gVersion="1.0";
    char* const gDescription="Native Mercurial Support for Dreamweaver.";
    
    
    DLL_EXPORT struct itemInfo
    {
        bool isFolder;
        int month;
        int day;
        int year;
        int hour;
        int minutes;
        int seconds;
        char type[256];
        int size;
    };
    
    
    // Description: This function asks the DLL to return its name and description, which appear in the Edit Sites dialog box. The name appears in the Server Access pop-up menu (for example, sourcesafe, webdav, perforce) and the description below the pop-up menu.
    // name: The name argument is the name of the source control system. The name appears in the combo box for selecting a source control system on the Source Control tab in the Edit Sites dialog box. The name can be a maximum of 32 characters. 
    DLL_EXPORT bool SCS_GetAgentInfo(char name[32],char version[32], char description[256], const char * dwAppVersion)
    {
        name=gName;
        version=gVersion;
        description=gDescription;
        return true;
    }
    //Description: This function connects the user to the source control system. If the DLL does not have log-in information, the DLL must display a dialog box to prompt the user for the information and must store the data for later use.
    DLL_EXPORT bool SCS_Connect(void **connectionData, const char siteName[64])
    {
        return true;
    }
    DLL_EXPORT bool SCS_Disconnect(void *connectionData)
    {
        return true;
    }
    DLL_EXPORT bool SCS_IsConnected(void *connectionData)
    {
        return true;
    }
    DLL_EXPORT int SCS_GetRootFolder_Length(void *connectionData)
    {
        return 0;
    }
    DLL_EXPORT bool SCS_GetRootFolder(void *connectionData, char remotePath[],const int folderLen)
    {
        return true;
    }
    DLL_EXPORT int SCS_GetFolderListLength(void *connectionData, const char *remotePath)
    {
        return 0;
    }
    DLL_EXPORT bool SCS_GetFolderList(void *connectionData, const char *remotePath, itemInfo itemList[ ], const int numItems)
    {
        return true;
    }
    DLL_EXPORT bool SCS_Get(void *connectionData, const char *remotePathList[], const char *localPathList[], const int numItems)
    {
        return true;
    }
    DLL_EXPORT bool SCS_Put(void *connectionData, const char *localPathList[], const char *remotePathList[], const int numItems)
    {
        return true;
    }
    DLL_EXPORT bool SCS_NewFolder(void *connectionData,const char *remotePath)
    {
        return true;
    }
    DLL_EXPORT bool SCS_Delete(void *connectionData, const char *remotePathList[],const int numItems)
    {
        return true;
    }
    DLL_EXPORT bool SCS_Rename(void *connectionData, const char * oldRemotePath, const char*newRemotePath)
    {
        return true;
    }
    DLL_EXPORT bool SCS_ItemExists(void *connectionData,const char *remotePath)
    {
        return true;
    }
    
    1 回复  |  直到 16 年前
        1
  •  1
  •   torhu    16 年前

    根据文档,在DreamWaver接受您的DLL之前,您可能需要添加所有必需的函数。你可以使用 Dependency Walker 的配置文件模式,以查看当dw加载dll时会发生什么。还要验证您的dll是否确实导出了所有必需的符号。

    编辑:在Dependency Walker的模块树或模块列表中选择您的dll,然后查看右侧的导出列表(在第一列标题中显示“e”),并确保所有必需的函数都在那里。如果GetProcessAddress在某个必需的函数上失败,则需要添加该函数。