繁体   English   中英

构建与Dreamweaver兼容的C DLL

[英]Building a C DLL compatible with Dreamweaver

我要参考的文档在这里,并且很简短: http : //livedocs.adobe.com/zh_CN/Dreamweaver/9.0_API/help.html?content=dwr_sourcecontrol_so_01.html

我遇到的问题是我不确定如何编译实际的DLL。 adobe扩展论坛上的最新答复是3个月大的,我不确定该问题在哪里。

令我困惑的编程部分是我必须使用C ++构建DLL,但是大多数教程都是基于构建目标应用程序包括的头文件来进行的。 (我是DLL编程的新手。)Dreamweaver仅需要一个DLL,并且它已经知道它将调用什么。 我对如何将这些信息单独放在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:依赖行者返回:

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来源:

dllheader.h

#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

main.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;
}

根据文档,您可能需要添加所有必需的功能,然后Dreamwaver才能接受您的DLL。 您可以使用Dependency Walker的配置文件模式来查看DW加载DLL时发生的情况。 并验证您的DLL确实导出了所有必需的符号。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM