|
I've used the Windows Media Player control in Native C++, Managed C++, and Silverlight,
and every time it took one or two lines of code to play a video...
If you really want to know how to use the control, the
Windows Media Player SDK[^]
is the ultimate source of info.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
#include "stdafx.h"
using namespace System;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::IO;
using namespace System::Text;
void main(void)
{
Stream^ fS = gcnew FileStream("D:\\TextOut.txt", FileMode::Create, FileAccess::Write);
StreamWriter^ sWriter = gcnew StreamWriter(fS);
Console::WriteLine("Encoding type : " + sWriter->Encoding->ToString());
Console::WriteLine("Format Provider : " + sWriter->FormatProvider->ToString());
sWriter->WriteLine("Today is {0}", DateTime::Today.DayOfWeek);
sWriter->WriteLine("Today we will mostly be using StreamWriter");
for (int i = 0; i < 5; i++)
sWriter->WriteLine("Value {0}, its square is {1}", i, i * i);
sWriter->Write("Arrays can be written : ");
array<system::char xmlns:system="#unknown">^ myArray = gcnew array<system::char>(5) { 'a', 'r', 'r', 'a', 'y' };
sWriter->Write(myArray);
sWriter->WriteLine("\r\nAnd parts of arrays can be written too");
sWriter->Write(myArray, 0, 3);
sWriter->Close();
fS->Close();
}</system::char></system::char></char>
The error is
error C2664: 'void System::IO::TextWriter::Write(cli::array<type,dimension> ^,int,int)' :
cannot convert parameter 1 from 'cli::array<type> ^' to 'cli::array<type,dimension> ^'.</type>
If I declare the array as array<char>, I get errors. But when I declare it as Char, there isn't any error.
And there is one more thing,
the Write() method for StreamWriter have only four overloads (the IntelliSense only shows four), but in MSDN it shows more than it 17... Why whats wrong here?
For instance, there is a Write() StreamWriter.Write Method (System.IO) method that takes a Boolean parameter, but when I write the following statement it generates an error
sWriter->Write(true);
Writes a
modified on Tuesday, January 20, 2009 11:45 AM
|
|
|
|
|
Ahmed Manzoor wrote: For instance, there is a Write() StreamWriter.Write Method (System.IO) method that takes a Boolean parameter, but when I write the following statement it generates an error
The following code works as expected in VS2008
FileStream ^ fs = gcnew FileStream("testfile.txt", System::IO::FileMode::Create);
StreamWriter ^ sw = gcnew StreamWriter( fs);
sw->Write( true);
sw->Close();
fs->Close();
delete sw;
delete fs;
led mike
|
|
|
|
|
array^ myArray = gcnew array(5) { 'a', 'r', 'r', 'a', 'y' }; should be
array<wchar_t>^ myArray = gcnew array<wchar_t>(5) { 'a', 'r', 'r', 'a', 'y' };
array requires a type, and in this case 'wchar_t'!
StreamWriter::Write (with 4 overloads) is the overloaded version of TextWriter::Write that has 17 overloads.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
I want to connect the SQL server 2005 through VC++ with out using ADO.net application. I have achieved through ADO.net. So i need some exmple plz provides.
With regards
Mahesh
|
|
|
|
|
Aren't you using C++/CLI?
|
|
|
|
|
No,
I want to create dll application, so i want win32 application.
|
|
|
|
|
HI,
How to open the ms excel file in VC++through programmaticaly,
Plz provide some code.
with regards
Mahesh
|
|
|
|
|
I think you need a VSTO project for doing programming with Excel.
Try looking into the Microsoft.Office.Tools.Excel namespace this might be what you need. Although I haven't worked with it, so I'm not sure.
|
|
|
|
|
Hi to all,
I have a problem with sending data with udp and sendto function.. I'm working on a server program that has a receiver and sender thread..every thread has it's own created SOCKETs that receives/send data from/to clients (respectively) but for some reason sendto function doesn't send packets.. it returns correct value of bytes send, but no packet is on the wire (checked with the Wireshark and winPCAP).. searched for solution, but could not find anything..
can anyone know what could be error?..
|
|
|
|
|
If you're using .NET, why not use the .NET classes for this sort of stuff ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i'm not using .net, just plain old c/c++ code.. simpler than that cannot be ..
|
|
|
|
|
Well, then this is wrong forum. You can try C++/MFC instead.
|
|
|
|
|
IKoB wrote: ...plain old c/c++ code.. simpler than that cannot be
...unless you're using .NET...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I want to write an application that contacts to another application over internet.
I don't want to user a web service... because the application may send files,voic,video ,etc.
please help me.
thank you
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
What do I need to build a Tic Tac Toe game online, in which two peoples can play?
I need to learn its networking side. I mean to what extent I need to learn network programming. Where are C++/CLI tutorials available for networking? Books? Just tell me requirements for connecting the two players...
Thanks
|
|
|
|
|
Ahmed Manzoor wrote: Just tell me requirements for connecting the two players...
You can do this in several ways. If you use TCP for communication, read about socket[^] class and TCPListener[^] class.
Other way is to write a web service or WCF service where program running on two players will be communicating.
|
|
|
|
|
I don't understand all this networking jargon ...
I think I need to understand networking then go on to programming. Can you suggest any tutorials?
|
|
|
|
|
I think you should read Microsoft's documentation on sockets, you'll see that sending and receiving data over a network is really easy. You don't need to know much about networks to make your application functional.
|
|
|
|
|
I have learned networking and yet have implemented a game to be playable over network.
I don't know why you are replying to old posts
|
|
|
|
|
I am using the method which taught in <<http://www.codeproject.com/KB/office/automate_excel.aspx>> to link one of the form of the project to excel, it works.However, when I try to link another form of the same project to the excel ..it fails
It gives out the following error:
using namespace Microsoft::Office::Interop::Excel;
1>c:\users\issac\documents\visual studio 2008\projects\fyp\fyp\day.h(13) : error C3083: 'Microsoft': the symbol to the left of a '::' must be a type
1>c:\users\issac\documents\visual studio 2008\projects\fyp\fyp\day.h(13) : error C3083: 'Office': the symbol to the left of a '::' must be a type
1>c:\users\issac\documents\visual studio 2008\projects\fyp\fyp\day.h(13) : error C3083: 'Interop': the symbol to the left of a '::' must be a type
I have tried to remove the reference and add the refernce again and rebuild the solution and it still fails..Has anyone try to run the excel in two different form in the same project before? Can anyone give me some suggestion to solve it..Thanks for your kind help.
modified on Saturday, January 17, 2009 7:40 AM
|
|
|
|
|
good afternoon everybody,
i have an query regarding crystal report
i have a problem while exporting report in excel some fields are suppress when i m using following code on suppress of related fields. i m doing this to suppress duplicate data value.
WhilePrintingRecords;
stringVar MFIELD1= {ado.txt1};
BOOLEANVAR MFIELD11=FALSE;
IF MFIELD1= {ado.txt1} THEN MFIELD11:=TRUE ELSE MFIELD11:=FALSE;
MFIELD1:= {ado.txt1};
if MFIELD11 = FALSE then false else true;
pls guide me to resolve this problem
thank you
|
|
|
|
|
Hi, I'm trying to use a library which was written in C#, in my managed c++ program. To use this library in a C# program you have to use the 'using' statement.
example:
using (new LibraryObject())
{
.. do some work ..
}
Besides the namespace 'using' statement I don't think managed c++ has this statement. Is there a statement comparable to this in managed c++, or is there at least some way of going about using this library's functionality the intended way without a using statement?
Here's a link to the library: http://www.codeproject.com/KB/cpp/WaitCursor.aspx
Thanks for the help!
|
|
|
|
|
1) Implicit with C++ Stack Semantics[^]:
LibraryObject libobj;
2) Explicit with try/finally blocks:
LibraryObject^ libobj;
try
{
libobj = gcnew LibraryObject();
}
finally
{
if (libobj != nullptr)
delete libobj;
}
More info on how C++ implements disposable types...
Destructors and Finalizers in Visual C++[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
using namespace System;
using namespace System::Threading;
ref class MyThread
{
public:
static void ThreadFunc1();
static void ThreadFunc2();
};
void MyThread::ThreadFunc1()
{
Console::WriteLine("Before long sleep");
try
{
Thread::Sleep(Timeout::Infinite);
}
catch(ThreadInterruptedException^){}
Console::WriteLine("After long sleep");
}
void MyThread::ThreadFunc2()
{
for (int i = 0; i < 5; i++)
{
Console::WriteLine("Thread {0}",i.ToString());
Thread::Sleep(2);
}
}
void main()
{
Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc1));
Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc2));
Console::WriteLine("Sleep/interrupt thread");
thr1->Start();
Thread::Sleep(4);
for (int i = 0; i < 4; i++)
{
Console::WriteLine("**Main2 {0}", i.ToString());
Thread::Sleep(2);
}
thr1->Interrupt();
thr1->Join();
Console::WriteLine("\nSuspend/resume thread");
thr2->Start();
Thread::Sleep(8);
thr2->Suspend();
for (int i = 0; i < 4; i++)
{
Console::WriteLine("**Main1 {0}", i.ToString());
Thread::Sleep(2);
}
thr2->Resume();
}
This program hangs sometimes, so I'm sure there is a deadlock between the threads but I can't catch it.
It mainly stops in the code highlighted...
|
|
|
|