異なるソリューションの連結方法とは?

このQ&Aのポイント
  • プログラミング初心者のための異なるソリューションの連結方法について解説します。開発環境やソースコードの例を交えながら、連結の手順を詳しく説明します。
  • ソリューションAとソリューションBのCPPファイルの連結方法を紹介します。具体的なコードの例を示しながら、連結手順を分かりやすく解説します。
  • 異なるソリューションを連結する際に考慮すべきポイントや注意点について解説します。連結時のエラーの対処法やバージョンの互換性についても触れます。
回答を見る
  • ベストアンサー

異なるソリューションの連結について教えてください。

プログラミング初心者です。 開発環境 OS  XP HomeEdition Visual C++ Express Edition ソリューションAのCPPファイル #include "DxLib.h" int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { if( DxLib_Init() == -1 ) // DXライブラリ初期化処理 { return -1; // エラーが起きたら直ちに終了 } DxLib_End() ; // DXライブラリ使用の終了処理 return 0 ; // ソフトの終了 } ソリューションBのCPPファイル #include "stdafx.h" #include <stdio.h> #include <windows.h> #include <string> using namespace System; using namespace System::Data; using namespace System::Data::SqlClient; int main(void){ String^ str; SqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\SOUTUKEN\\TEST.mdf;Integrated Security=True;User Instance=True"); sqlConn->Open(); str = "SELECT * FROM table1 "; //str= "INSERT INTO table1 (test) VALUES(3)"; SqlCommand^ sqlCmd = gcnew SqlCommand(str,sqlConn); SqlDataReader^ exeReader = sqlCmd->ExecuteReader(); while( exeReader->Read() ) { System::Diagnostics::Debug::WriteLine(exeReader["test"]->ToString()); } sqlConn->Close(); } です。ソリューション間の連結するのはどうしたらいいですか?

質問者が選んだベストアンサー

  • ベストアンサー
  • yamatonbo
  • ベストアンサー率100% (4/4)
回答No.1

もしかして、クラスの呼び出しのことですか?

9oo_001
質問者

お礼

そうかもしれません。返答ありがとうございます。

関連するQ&A

  • 名前空間使用するには

    開発環境  XP Home Edition Microsoft Visual C++ 2008 Express Edition です。 #include "DxLib.h" #include <Windows.h> #include <string> #include <stdio.h> using namespace System; using namespace System::Data; using namespace System::Data::SqlClient; void in(){ String^ str; SqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\SOUTUKEN\\TEST.mdf;Integrated Security=True;User Instance=True"); sqlConn->Open(); str = "SELECT * FROM table1 "; //str= "INSERT INTO table1 (test) VALUES(3)"; SqlCommand^ sqlCmd = gcnew SqlCommand(str,sqlConn); SqlDataReader^ exeReader = sqlCmd->ExecuteReader(); while( exeReader->Read() ) { Diagnostics::Debug::WriteLine(exeReader["test"]->ToString()); } Diagnostics::Debug::WriteLine( "表示テスト %s \n"); sqlConn->Close(); } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { if( DxLib_Init() == -1 ) // DXライブラリ初期化処理 { return -1; // エラーが起きたら直ちに終了 } DxLib_End() ; // DXライブラリ使用の終了処理 in(); return 0 ; // ソフトの終了 } プロジェクトのプロパティはDxライブラリの設定にしています。 http://homepage2.nifty.com/natupaji/DxLib/dxuse_vc2008express.html ここのサイトの通りにやっています。 知識不足なところもありますがお願いします。

  • VC++でSELECT文の実行結果を表示

    開発環境は OS XPのHomeEditon Visual C++ ExpressEdition SQL Server 2005 Express です。 よろしくお願いします。 #include "stdafx.h" #include <stdio.h> #include <windows.h> #include <string> using namespace System; using namespace System::Data; using namespace System::Data::SqlClient; char a; void sub( SqlDataReader ^objRd ) { System::Diagnostics::Debug::WriteLine(objRd); while( objRd->Read() ) { System::Diagnostics::Debug::WriteLine(objRd->Read()); } } int main(void){ String^ str; SqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\SOUTUKEN\\TEST.mdf;Integrated Security=True;User Instance=True"); sqlConn->Open(); str = "SELECT * FROM table1"; SqlCommand^ sqlCmd = gcnew SqlCommand(str,sqlConn); SqlDataReader^ exeReader = sqlCmd->ExecuteReader(); sub( exeReader ); sqlConn->Close(); } これの実行結果がboolean形で帰ってくるのですがこれを表内のデータが帰ってくるようにしたいのです。 少し知識不足なところもありますがどうかよろしくお願いします。

  • VC++でSQLへSELECT文を送ったのですが…

    #include "stdafx.h" #include <stdio.h> #include <windows.h> #include <string> using namespace System; using namespace System::Data; using namespace System::Data::SqlClient; char a; int main(void) { String^ str; SqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\○○\\test.mdf;Integrated Security=True;User Instance=True"); sqlConn->Open(); str = "Select test FROM Table1"; SqlCommand^ sqlCmd = gcnew SqlCommand(str,sqlConn);// SqlDataReader^ ExecuteReader (); sqlConn->Close(); } int sub() { a = ExecuteReader; printf (a,"表示テスト\n"); return 0; } の構文でSQL ServerへSELECT文を送り、そこで得た結果を 表示しようと思ったのですが 1>select-test.cpp 1>.\select-test.cpp(28) : error C2065: 'ExecuteReader' : 定義されていない識別子です。 1>.\select-test.cpp(29) : error C2664: 'printf' : 1 番目の引数を 'char' から 'const char *' に変換できません。 (新しい機能 ; ヘルプを参照) 1> 整数型からポインタ型への変換には reinterpret_cast、C スタイル キャストまたは 関数スタイル キャストが必要です。 と2つのエラーを返されてしまいました。 開発環境は OS XPのHomeEditon Visual C++ ExpressEdition SQL Server 2005 Express です。 よろしくお願いします。

  • 文字列の連結について

    開発環境 XP Home Edtion SQL Server2005 Express Edtion DBから選択してきたその値に .png という文字列を繋げて対応する画像を表示を反映させたいのですがどのようにすればよいですか? String^ str; SqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\SOUTUKEN\\TEST.mdf;Integrated Security=True;User Instance=True"); sqlConn->Open(); str = "SELECT gazou FROM table1 WHERE gazou=1"; SqlCommand^ sqlCmd = gcnew SqlCommand(str,sqlConn); SqlDataReader^ exeReader = sqlCmd->ExecuteReader(); while(exeReader->Read() ) { str3=exeReader["gazou"]->ToString(); System::Diagnostics::Debug::WriteLine(str3); HDC hMdc; char* dstChar3; dstChar3 = (char*)(void*)Marshal::StringToHGlobalAnsi(str3); LPCSTR dstLPCSTR3; dstLPCSTR3 = (LPCSTR)dstChar3; LPCSTR name = "'"+dstLPCSTR3+"'.png"; HBITMAP hbmp = (HBITMAP)LoadImage( NULL, name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION ); hMdc= CreateCompatibleDC(hdc ); SelectObject(hMdc, hbmp ); BitBlt(hdc, 0, 0, 2000, 5000, hMdc, 0, 0, SRCCOPY); DeleteDC(hMdc); DeleteObject(hbmp); } sqlConn->Close(); なにとぞよろしくお願いします。

  • NULL値をSELECTする

    開発環境  Xp Home Edtion Microsoft Visual C++ 2008 Express Edition Microsoft SQL Server 2005 int i=0; String^ str1; sSqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\SOUTUKEN\\test.mdf;Integrated Security=True;User Instance=True");qlConn->Open(); str1= "SELECT NoID FROM Table1 WHERE hentou IS NULL OR nyuryoku IS NULL"; sqlCommand^ sqlCmd=gcnew SqlCommand(str1,sqlConn); SqlDataReader^ exeReader=sqlCmd->ExecuteReader(); while(exeReader->Read()){ gyou[i]=exeReader[""]->ToString(); i++; } sqlConn->Close(); SELECT文でhentou,nyuryokuのどちらか一方でもNULLならばそのNoIDを取り出すということをしたいのですが、 "sqlCommandが定義されていない識別子です。"というエラーが出てきます。 SQL文が間違っていると思うのですがどのようにしたら良いのでしょうか何卒よろしくお願いします。

  • 文字列変換ついて

    開発環境  XP Home Edtion Microsoft Visual C++ 2008 Express Edition Microsoft SQL Server 2005 Express Edition Visual C++で入力フォームから数字の入力文字列でのInsert文を実行してそのまま反映させることはできたの ですが、日本語やアルファベットが入らないのですがどうしたらよいでしょうか? PSTR strText; String^ data; char *ree; ree=(char*)strText; String^ data; data=gcnew String(ree); SqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\SOUTUKEN\\test.mdf;Integrated Security=True;User Instance=True"); sqlConn->Open(); str= "INSERT INTO table1 (test) VALUES("+data+")"; SqlCommand^ sqlCmd = gcnew SqlCommand(str,sqlConn); SqlDataReader^ exeReader = sqlCmd->ExecuteReader(); sqlConn->Close(); 何卒よろしくおねがいします。

  • テキストボックスに文字列を入れる

    開発環境 XP Home Edtion Microsoft Visual C++ 2008 Express Edition Microsoft SQL Server 2003 Express Edition SQL文で1から5までのNoIDを取得してそれをダイアログのテキストボックスIDC_XS1からIDC_XS5の場所に入れようとしています。 int i=1; String^ str; char* dstChar2; LPSTR dstLPSTR2; SqlConnection^ sqlConn = gcnew SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\SOUTUKEN\\test.mdf;Integrated Security=True;User Instance=True"); while(i<=5){ sqlConn->Open(); str= "SELECT * FROM Table1 WHERE NoID='"+i+"'"; SqlCommand^ sqlCmd = gcnew SqlCommand(str,sqlConn); SqlDataReader^ exeReader = sqlCmd->ExecuteReader(); while(exeReader->Read()){ str=exeReader["nyuryoku"]->ToString(); dstChar2 = (char*)(void*)Marshal::StringToHGlobalAnsi(str); dstLPSTR2 = (LPCSTR)dstChar2; #define IDC_XS IDC_XS##i        //iの内容をIDC_XSに連結させたいのですがなかなかできないのです。 SetDlgItemText(hWnd,IDC_XS,dstLPSTR2); i++; } sqlConn->Close(); どのようにしたらテキストボックス5つの中にSQL文の結果が入るのでしょうか。何卒よろしくおねがいします。

  • VC++メッセージの送受信について教えてください。

    VC++でソフトを作成しています。 初心者なのでわからないことだらけです。 どなたかご教授お願いします。 ■環境 Windows xp mode Visual Studio 2010 Professional VC++ フォームアプリケーション .net Framework4.0 ■相談内容 アプリ1のtextBoxに入力された文字列をアプリ2に送信して、アプリ2のtextBoxに表示させたいのですが、PostMessageを使用するとメッセージが送れません。 また、SendMessageを使用すると送れますが、共有メモリを使用すると文字列が途中で途切れてしまいます。 PostMessageと共有メモリの使用は指令なのではずせません。 理由は送信側のアプリがロックされるのを防ぐため、後に多数のアプリから送信した文字列を取得できるようにするためです。 下記にソースコードを記載しますので、どこが悪いのか、何が原因でそうなるのか、どうすれば正常に動作するようにできるのかを教えてください。 特に、ソースについてはどこをどのように直せば良いかを教えていただけるとありがたいです。 ~送信側ソース~ #pragma once #include<windows.h> #include<iostream> #include<fstream> #include<string> #include<msclr/marshal.h> #pragma comment(lib,"user32.lib") int s; using namespace std; using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Runtime::InteropServices; using namespace msclr::interop; [DllImport("user32.dll") ] extern System::String^ FindWindow(String^ lpClassName, String^ lpWindowName); [DllImport("user32.dll")] extern System::String^ PostMessage(HWND hWnd, int Msg, int wParam, int lParam); public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { System::String^ moji_textBox4; moji_textBox4=textBox4->Text; s=textBox4->Text->Length+1; COPYDATASTRUCT cd; HWND hWnd; char buffer[500]; sprintf_s(&buffer[0],5,"%s",moji_textBox4); cd.dwData=0; cd.cbData=s;//strlen(buffer)+1; cd.lpData=buffer; hWnd=::FindWindow(nullptr,L"アプリ2"); ::PostMessage((HWND)hWnd,WM_COPYDATA,0,(LPARAM)&cd); ~受信側ソース~ #pragma once #pragma comment(lib,"user32.lib") #include<ctype.h> #include<windows.h> #include<msclr/marshal.h> using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Runtime::InteropServices; using namespace msclr::interop; public: virtual void WndProc(System::Windows::Forms::Message% msg) override { if(msg.Msg== WM_COPYDATA) { COPYDATASTRUCT *cd; cd=(COPYDATASTRUCT *)msg.LParam.ToInt32(); System::String^ str; str=gcnew System::String((char *)cd->lpData); pin_ptr<const wchar_t>pstr=PtrToStringChars(str); System::String^ ShareMemoryName1=L"Information"; HANDLE hmap; char *pmap; marshal_context^ context= gcnew marshal_context; LPCTSTR ShareMemoryName2 = context->marshal_as<LPCTSTR>(ShareMemoryName1); hmap=::CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0,2048, (LPCTSTR)ShareMemoryName2); pmap=(char *)::MapViewOfFile(hmap,FILE_MAP_ALL_ACCESS,0,0,1024); System::String^ pstr1= gcnew System::String(pstr); ZeroMemory(pmap,2048); memcpy_s(pmap,2048,pstr,sizeof(pstr)); System::String^ str1; str1= gcnew System::String((char *)pmap); textBox6->Text=str1; UnmapViewOfFile(pmap); CloseHandle(hmap); } Form::WndProc(msg); }

  • 空白を含む名前のファイル等を

    受け取るプログラムで ”x y.txt”が一つのファイルと見なされるようにするため yoppiiさんに GetCommandLine() を使うのをやめて __argvや__argc すればいいという事を教えてもらいいったん解決したのですが いろいろ調べてみるとまずい場合がまだあるということがわかりました Windows95のc:\My documをドラッグ実行した場合です 試験用アプリは #include <windows.h> #include <string> using namespace std; WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) { string str=""; for(int i=0;i<__argc;str=str+'<'+__argv[i++]+">\n"); MessageBox(NULL,str.c_str(),"Command",MB_OK); return 0; } です 対処方法を教えてください

  • 別スレッドからメインスレッドのテキストボックスに文字を表示させたい

    Visual C++ 2005 Express Editionを使用している初心者です。 タイトルの方法がどうしてもわからないので教えてください。 うまく説明できないので聞きたいところのコードを載せます。 //SAMPLE.cpp #include "stdafx.h" #include "Form1.h" using namespace SAMPLE; int main(array<System::String ^> ^args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Application::Run(gcnew Form1()); } //Form1.h #include <process.h> #include <vcclr.h> namespace SAMPLE { unsigned __stdcall counter(void *arg); int thread_id1; unsigned dummy; using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public:Form1(void) { InitializeComponent(); //別スレッド起動 thread_id1=_beginthreadex(NULL,0,counter,(void *)1,0,&dummy); } private: System::Windows::Forms::TextBox^ textBox1; private: System::ComponentModel::Container ^components; void InitializeComponent(void) { this->textBox1 = (gcnew System::Windows::Forms::TextBox()); //省略(コンポーネント初期化) } private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } }; unsigned __stdcall counter(void *arg){ //別スレッド //ここで文字列を記述して上のtextBox1に表示したい return 0; } } 初歩的なことかもしれませんが、 よろしくお願いします。

専門家に質問してみよう