在BCB中怎样调用API函数?
才学BCB, 有几个问题需要澄清
1、在BCB中怎样调用API 函数
2、API在VB中使用的名字参数等,适合BCB中一样吗,怎样将VB 的声明转成BCB声明
比如:
Declare Function AddPrintProcessor Lib "winspool.drv" Alias "AddPrintProcessorA" (ByVal pName As String, ByVal pEnvironment As String, ByVal pPathName As String, ByVal pPrintProcessorName As String) As Long
为指定的系统添加一个打印处理器
Long,非零表示成功,零表示失败。会设置GetLastError
pName ---------- String,指定要在其中安装驱动程序的一台服务器的名字。对于本地系统,设为vbNullString
pEnvironment --- String,要在其中添加打印处理器的一个环境(如“Windows
NT x86”)。对于当前(本地)系统环境,则设为vbNullString
pPathName ------ String,包含了打印管理器的一个文件的名字。文件必须位于打印处理器目录中
pPrintProcessorName - String,打印处理器的名字
我下载到一个很全的API资料但是是for vb的怎样改为 for bcb
问题点数:20、回复次数:13Top
1 楼ylp92155(一只菜鸟)回复于 2002-11-15 08:32:49 得分 0
资料是有一部分是英文的,谁有兴趣将它译成中文,并配上bcb 例程?Top
2 楼yinglang(影狼)回复于 2002-11-15 08:32:51 得分 1
直接使用就可以了,不需要声明Top
3 楼ylp92155(一只菜鸟)回复于 2002-11-15 08:36:03 得分 0
参数弄不明白
新手,最好有例子,按葫芦画瓢才行Top
4 楼ylp92155(一只菜鸟)回复于 2002-11-15 08:37:25 得分 0
有能系统讲一下的吗?Top
5 楼fsstolw(fsstolw)回复于 2002-11-15 08:52:58 得分 1
推荐一本书吧一定对你有用:
C++Builder与Windows API经典范例
因为是才买,所以也说不出什么名堂来,只好你自己找找这本书看咯。Top
6 楼sunnykong(空空)回复于 2002-11-15 11:36:00 得分 10
1.只要BCB自带的库中有你说的API函数的库声明,你就可以在程序里直接使用API函数,如果没有你就只好自己找一个了,当然你也可以直接使用相应的*.dll。
2.建议你遇到这种问题,查一下MSDN,以下是我查到的关于你那个API函数的说明:
AddPrintProcessor
The AddPrintProcessor function installs a print processor on the specified server and adds the print-processor name to an internal list of supported print processors.
BOOL AddPrintProcessor(
LPTSTR pName, // pointer to server name
LPTSTR pEnvironment, // pointer to environment name
LPTSTR pPathName, // pointer to path
LPTSTR pPrintProcessorName // pointer to print-processor name
);
Parameters
pName
Pointer to a null-terminated string that specifies the name of the server on which the print processor should be installed. If this parameter is NULL, the print processor is installed locally.
pEnvironment
Pointer to a null-terminated string that specifies the environment (for example, "Windows NT x86", "Windows NT R4000", "Windows NT Alpha_AXP", or "Windows 4.0"). If this parameter is NULL, the current environment of the caller/client (not of the destination/server) is used.
pPathName
Pointer to a null-terminated string that specifies the name of the file that contains the print processor. This file must be in the system print-processor directory.
pPrintProcessorName
Pointer to a null-terminated string that specifies the name of the print processor.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, callGetLastError.
Remarks
Before calling the AddPrintProcessor function, an application should verify that the file containing the print processor is stored in the system print-processor directory. An application can retrieve the name of the system print-processor directory by calling the GetPrintProcessorDirectory function.
An application can determine the name of existing print processors by calling the EnumPrintProcessors function.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winspool.h.
Import Library: Use winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Top
7 楼szbug(深圳虫)回复于 2002-11-15 11:54:54 得分 1
直接用就行了。。。。Top
8 楼tjzzx888(青草)回复于 2002-11-15 12:41:24 得分 1
直接用Top
9 楼ylp92155(一只菜鸟)回复于 2002-11-15 16:59:58 得分 0
sunnykong(空空)
API 函数在MSDN上全能查到,对吧?Top
10 楼shadowstar(CodeFast for Delphi & C++Builder)回复于 2002-11-17 15:07:06 得分 1
建议先看一下C/C++之类的书Top
11 楼cdws222(二当家)回复于 2002-11-17 15:36:56 得分 3
在BCB中用API不用声明.h文件里已经声明好了,例:MessageBox(Handle,"这是对话框","这是标题",MB_OK | MB_ICONERROR);这就是一个API,直接用就行了Top
12 楼xlRiver()回复于 2002-11-21 17:58:20 得分 1
对,直接使用,不有声明,方便啊!!!
Top
13 楼losthold(呵呵)回复于 2002-11-22 14:10:43 得分 1
在函数前加"::"就可以直接调用api函数了Top




