编译DLL出错,需要急救,100分征求解答!(100分)

  • 主题发起人 yforrest
  • 开始时间
Y

yforrest

Unregistered / Unconfirmed
GUEST, unregistred user!
用VC编译一个DLL,出错信息如下,哪位高手指点一下该如何解决:
test.h(25): error C2664: 'GetPathW': cannot convert parameter 2 from 'char [255]' to 'unsigned short *'
Types pointed to are unrelated;
conversion requires reinterpret_cast, C-style cast or function-style cast
 
数据类型不对,把调用GetPath的代码贴出来吧。
 
GetPath(255, fdir);
就这句
 
你的 fdir 是怎么声明的,还 GetPath原型。
 
private:
char fdir[255], fname[255];
定义如上
 
你是要用GetPaht吗?
The GetPath function retrieves the coordinates defining the endpoints of lines
and the control points of curves found in the path that is selected into the
specified device context.
int GetPath(
HDC hdc, // handle to device context
LPPOINT lpPoints, // pointer to array receiving path vertices
LPBYTE lpTypes, // pointer to array of path vertex types
int nSize // count of points defining path
);
我想你的原意是要得到程序所在路径吧,那不用GetPath()
而要用GetCurrentDirectory
char str[MAX_PATH];

GetCurrentDirectory(MAX_PATH,str);
MessageBox(str);
 
lstrcpy(ext, ".mss");
GetTempFileName(fdir, "", 0, fn)
DeleteFile(fn);
GetTempPath(255, fdir);
还有上面几处,都是和上面一样相同的错误提示信息。为什么啊?
 
这几个好象没错,那个GetPath你照我说的改过吗???
 
上面那个GetPath我搞错了,是GetTempPath(255, fdir);
lstrcpy(ext, ".mss");
GetTempFileName(fdir, "", 0, fn)
DeleteFile(fn);
GetTempPath(255, fdir);
都是差不多的错误提示信息:
cannot convert parameter 2 from 'char [255]' to 'unsigned short *'
cannot convert parameter 1 from 'char [255]' to 'const unsigned short *'
Types pointed to are unrelated;
conversion requires reinterpret_cast, C-style cast or function-style cast
 
先Rebuild All,4行都是这个错吗?
 
对,都是这种错误信息。
 
我在 BCB 中试过了,没错的。
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char fdir[255], fname[255];
GetTempPath(255, fdir);
ShowMessage(fdir);
}
 
终于搞定了。修改了编译环境配置,把Win32 Unicode Release MinSize改为了
Win32 Release MinSize。
问题是解决了,有谁可以解释一下其中的区别啊?还有MinDependency
 
There are several possible project configurations for C++ projects available via 
the Build - Set Active Configuratuion menu. For example, when creating a brand
new COM object using ATL COM AppWizard the choices are: Win32 Debug,
Win32 Unicode Debug, Win32 Release MinSize, Win32 Release MinDependency,
Win32 Unicode Release MinSize, and Win32 Unicode Release MinDependency.
Some of these configurations may be removed (using the Build - Configurations
menu). You can also create new ones (configurations with different names),
based on existing ones. To make things simple I have decided to keep only 2
configurations available for my C++ samples: Debug (based on Win32 Debug), and
Release (based on Win32 Release MinSize). This should simplify sample code
distribution and builds because youdo
n't have to struggle with the Win32
Unicode Release MinDependency issue. This is the last configuration in the
default list. It gets selected automatically if the configuration list is
unchanged. This happens because the <ProjectName>.opt file is not distributed
with the source files.
 
这几种编译环境配置有什么不同吗?
 
In general Release builds are smaller than Debug builds, because more
information is place into the debug builds to help in debugging the application.
Much code is defined only for Debug versions to help in trackingdo
wn
problems, like providing ASSERTs. One common problem is having code within a
#ifdef _DEBUG block. This code is only run in debug mode. Another common
problem is placing a function call in an ASSERT and using the ASSERT to verify
a return, like: ASSERT(obj.foo(x, y) == true). The problem is that the ASSERT
is compiled out of the Release build, so the function call within the ASSERT is
never made.
Release MinSize builds your component with a dependency on the ATL.DLL file,
which means that machines that will run your component must have that DLL
installed on them.
Release MinDependencies statically likes the ATL.DLL code into your component,
so that it's not required on the target machine.
自己找到答案了
 
多人接受答案了。
 
顶部