怎么把vc++里面的cstring转换为C#中的string 或int float 急急急 一定给分

luluyy 2008-07-12 04:05:44
跟标题一样 在线等
...全文
530 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
jack99122 2009-07-13
  • 打赏
  • 举报
回复
CString s("JiangSu");
String^ str1=gcnew String(s);
这样就可以了
hoocode2008 2008-07-13
  • 打赏
  • 举报
回复
http://www.skinfeature.com
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 luluyy 的回复:]
。。。。为的就是把程序简单话 找那东西太麻烦 还不稳定~~ 接着等 就不信中国没能人
[/Quote]
搞编译器的ms都没能搞出来
luluyy 2008-07-12
  • 打赏
  • 举报
回复
==啊~ 烦死了 不懂C++
gomoku 2008-07-12
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 luluyy 的回复:]
。。。。为的就是把程序简单话  找那东西太麻烦 还不稳定~~  接着等 就不信中国没能人
[/Quote]

中国能人是很多。但不是人有多大胆,地有多大产。
做程序要讲究科学的方法。不能做的事情,等上十年公鸡也不会下蛋。
gomoku 2008-07-12
  • 打赏
  • 举报
回复
看不到导出的函数,你要贴导出到C#的函数。

如果你的dll是导出整个类的MFC扩展dll,那么C#不能直接用(只用MFC程序才能用扩展dll)。

luluyy 2008-07-12
  • 打赏
  • 举报
回复
。。。。为的就是把程序简单话 找那东西太麻烦 还不稳定~~ 接着等 就不信中国没能人
yagebu1983 2008-07-12
  • 打赏
  • 举报
回复
找个转换器试试!!!
luluyy 2008-07-12
  • 打赏
  • 举报
回复
// VCforALLDlg.h : header file
//

#if !defined(AFX_VCFORALLDLG_H__954EDFBA_4DE7_4080_AC06_C864638A3727__INCLUDED_)
#define AFX_VCFORALLDLG_H__954EDFBA_4DE7_4080_AC06_C864638A3727__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CVCforALLDlg dialog

class CVCforALLDlg : public CDialog
{
// Construction
public:
bool m_bLoaded;
CVCforALLDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CVCforALLDlg)
enum { IDD = IDD_VCFORALL_DIALOG };
CString m_strAddress;
CString m_strBirthday;
CString m_strName;
CString m_strNation;
CString m_strNumber;
CString m_strResult;
CString m_strSex;
CString m_strSignDate;
CString m_strValidate;
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CVCforALLDlg)
public:
virtual BOOL DestroyWindow();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CVCforALLDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnClose();
afx_msg void OnButtonRecgID();
afx_msg void OnButtonDDScanRecog();
afx_msg void OnButtonNIDScanRecog();
afx_msg void OnButtonOldIdScanRecog();
afx_msg void OnButtonPP();
afx_msg void OnButtonID2();
afx_msg void OnBtnCalibrate();
afx_msg void OnButtonPPR();
afx_msg void OnBtnScanOther();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_VCFORALLDLG_H__954EDFBA_4DE7_4080_AC06_C864638A3727__INCLUDED_)
gomoku 2008-07-12
  • 打赏
  • 举报
回复
你贴一小段使用CString的函数,让大家试试看改动的方法。
luluyy 2008-07-12
  • 打赏
  • 举报
回复
愁死~ 哪个兄台对C++了解深的话~我可以提供源代码~ 帮忙改一个~~ 分加倍~~~ 继续等!!!416700390@qq.com
luluyy 2008-07-12
  • 打赏
  • 举报
回复
现在呢 我是把C++的程序搬到C#上来~ 就是C++中的CSTRING 类型无法在c#中得到应用 也就是说转换不过来·所以程序无法进行~ 说的详细一点吧 提供个解决方案~· 最好有一段例子~~ 谢谢了·解决吧就加分!!
  • 打赏
  • 举报
回复
这两个东西差别太大,
要想传递字符串的话只能使用原始类型
gomoku 2008-07-12
  • 打赏
  • 举报
回复
如果你能有vc++源文件的话,把CString改成其他简单类型,比如LPWSTR等,或C#能理解的BSTR。

1、VC编译器知道CString的结构和类信息,并在CString超出作用域的地方,插入CString的析构函数。
2、但C#并不知道CString的具体实现,不知道如何把CString转换为C# string,也不会析构CString。
3、即使通过一些偏移量硬从CString得到内部的string,也很容易造成内存的泄漏。
4、其实就是都用C++,不用版本的CString也会造成麻烦。



110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧