直接用vb反复调用dll有时出错,出错后不能恢复正常。不知是何原因!
解决方案 »
- 点击另一应用程序中的某一位置怎样实现?
- 如何禁止修改datagrid
- 大家新年好!问题不难,就是奇怪,UP者也有分,分不够可以再加!谢谢!
- win2000professional 刚装完ado版本是多少?把ado 2.7也打包进去,要打哪些文件?只要一个msado15.dll文件吗?
- 这个网站:http://www.softwww.com 中的一款聊天软件,要出售源代码,我准备买一套,大家认为这样的软件的源代码值多少钱
- 有在金华这边搞VB开发的人吗
- 有关变量赋值失败的菜鸟问题
- 我想在VB中利用鼠标中间的滚轮
- .addnew 和 .update有何不同?
- 门框,领分,谢了
- 谁来露一手???刺激!
- 请教怎样将一个数组写入一个文件并在下次开机后自动读取?
1. Use the menus: New\Projects\Win32 Dynamic-Link Library. Enter the directory
where you want the VC++ project and the project name (MyFuncsProject in the
example).2. New\Files\C++ Source File. Check the Add To Project box. Enter the file name
(MyFuncs.cpp in the example).3. Enter the function's source code. Use __declspec to export the function's
symbol. Use 'extern "C"' to minimize name mangling by VC++. // Define DllExport to declare exported symbols.
#define DllExport __declspec( dllexport )
// Prototype the function.
// Use 'extern "C"' to minimize name mangling.
extern "C" DllExport long MyCFunc(long x);
// Define the function.
extern "C" DllExport long MyCFunc(long x)
{
return x * x;
}4. Set project options using Project\Settings. On the C/C++ tab, select the
Code Generation category. Then change Calling Convention to __stdcall.5. Select Build\Set Active Configuration. Select the Release configuration.
Repeat step 4 to make the options apply to the release configuration in addition
to the debug configuration. Use Build\Set Active Configuration to reselect the
debug configuration if desired.6. Build the project (press F7 or use the Build menu). This creates the
DLL file.7. In your Visual Basic program, declare the DLL function using the DLL file's
full path name. The function's name in the DLL file has been slightly mangled by
VC++. The name is an underscore, followed by the name you gave it, followed by
"@", followed by the number of bytes in the function's argument list. In this
example the name is _MyCFunc@4 because the function takes one 4 byte argument
(a long integer). Private Declare Function MyCFunc Lib _
"C:\VBHelper\VcDll\Method1\Release\MyFuncsProject.dll" _
Alias "_MyCFunc@4" _
(ByVal x As Long) As Long Private Sub Command1_Click()
Dim x As Long
Dim y As Long x = CInt(Text1.Text)
y = MyCFunc(x)
Label1.Caption = Str$(y)
End Sub*** HINT: To quickly determine the mangled name of the function, find the DLL
file in Windows Explorer. Right click on the file and select the "Quick View"
command. This presents an editor showing information about the DLL. Page down 2
or 3 pages and you will find a list of exported symbols available in the DLL.
One of these will be the mangled function name.8. Run the program.