gpt4 book ai didi

c++ - 构建与 Dreamweaver 兼容的 C DLL

转载 作者:行者123 更新时间:2023-11-28 08:27:52 24 4
gpt4 key购买 nike

我引用的文档在这里,相当简短,切中要点: http://livedocs.adobe.com/en_US/Dreamweaver/9.0_API/help.html?content=dwr_sourcecontrol_so_01.html

我遇到的问题是我不确定如何编译实际的 DLL。 adobe extension 论坛上的最后一个回复是 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 determines which features the library supports by calling GetProcAddress() for each API function. If an address does not exist, Dreamweaver assumes the library does not support the API. If the address exists, Dreamweaver uses the library's version of the function to support the functionality.

虽然我仍然不确定这对我编译的 DLL 意味着什么。

编辑 2:Dependency 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 源代码:

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 在所需函数之一上失败,您需要添加该函数。

关于c++ - 构建与 Dreamweaver 兼容的 C DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3302876/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com