|
发表于 2009-2-26 16:17:17
|
显示全部楼层
恩~~~虽然学C++,但是还是不懂很多~~
(下定决心回家把研发人员书库看一下~~)
如果想在你的japi里添加自己的japi函数(如FileReadBool和FileWriteBool)。就直接这样声明?
(在fileio.cpp里)
首先:[codes=C++]typedef long jBool;[/codes]
函数:
[codes=C++]
jBool jNATIVE FileReadBool(jInt hfile)
{
HANDLE hFile = (HANDLE)hfile;
DWORD dwRead;
jBool res;
if(ReadFile(hFile, &res, 4, &dwRead, NULL) < 0 || dwRead != 4)
return 0;
else
return res;
}
jBool jNATIVE FileWriteBool(jInt hfile, jBool v)
{
HANDLE hFile = (HANDLE)hfile;
DWORD dwRead;
if(WriteFile(hFile, &v, 4, &dwRead, NULL) < 0 || dwRead != 4)
return 0;
else
return 1;
}[/codes]
最后在DllMain中添加:
[codes=C++]
jAddNative(FileReadBool,"FileReadBool","(I)B");
jAddNative(FileWriteBool,"FileWriteBool","(IB)I");
[/codes]
fileio.j:
[codes=jass]
native FileReadBool takes integer fileid returns boolean
native FileWriteBool takes integer fileid, boolean value returns integer
[/codes]
是不是这样就成功了?
急~~~求LZ火速解答~~ |
|