|
Hi everybody
How can an application interact to a Windows Services or transact with it?
Tanks for your help
|
|
|
|
|
|
Hi...
Excuse me!
What is your mean?
|
|
|
|
|
|
Generally, through some form of inter-process communication, although for some simple interactions (start, stop, pause, resume a service) SCP is more than enough.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Hi!
Thanks for your help
But What is the "SCP" ?
Please explain more obviously!
|
|
|
|
|
|
I'm basically playing with static libraries, with header files that don't have any cpp files...i.e. all code for all header files in static library is inlined, and vs.net won't compile unless i include a cpp file that calls the header files.
Is this a normal practice with other compilers, or just for vs.net...and if just for vs.net, is their an option to disable that?
|
|
|
|
|
Right Click your header file ander soluton explorer and chose properties and under general chose don't use precomiled headers.
ps: I know this will work, but i am not 100% exactly where to find this setting, because i use public pc
|
|
|
|
|
hi for all
This is a simple question but I have no idea how I can do this:
How can I read all lines from a file and insert a new line in a specific local?
thanks a lot for all
Alex Cutovoi
|
|
|
|
|
<br />
#include <fstream><br />
std::ifstream ifs("path/to_file");
if (!ifs.is_open())<br />
{
<br />
std::string all_file,line;<br />
while( !ifs.eof() )<br />
{<br />
getline(ifs, line);<br />
all_file += line;<br />
if (line.empty())
continue;<br />
}<br />
after this while exists, you have in all_file, well, all file ...
then you can insert your stuff in string all_file, close the original file open it with "w" or so (make sure the write poinetr is at the beginning of the file), and then write the modified content, that is all_file.
-- modified at 3:16 Thursday 6th October, 2005
|
|
|
|
|
This is managed c++ forum, so it would be better to post managed code
|
|
|
|
|
to anonymous:
yo dude, according to my knowledges this forum is also related to plain C++ !!!. And beside that, reading all lines from a file, should merely follow the same idea, even in managed C (that is C#, not C++ ), right ?
Regards,
gecool
|
|
|
|
|
Hi all
Article "A light-weighted client/server socket class in C++" explains how to make a client/server application, but i am a beginner and want to know if there are tutorials out there that are simple to use and that explains, step by step, how to create the server application and the client application.
The apps should use sockets and be as simple as possible (basically just be able to wait for a request (server) and then send an acknowledgement to the client (just a basic text message). it should really only illustrate the basic phases: 1) idle(server waiting for a connection), (2)connection establishment, (3)data transfer, (4)termination.
I know that you need the ip address as well as well as a port for communication - but that is basically all i know
if there is anyone who can help by writing a basic program (or tutorial), or even refering me to websites (one for beginners, as all the websites i find are a bit advanced and confusing for the novice C++ network programmer), I would most certainly appreciate it.
thank you.
|
|
|
|
|
check out http://www.hal-pc.org/~johnnie2/winsock.html
|
|
|
|
|
Hey...
Im trying to use a small bit of c++ code but have never done a line of it in my life.
I am looking for some help porting it into something readable. Doesn't have to be another language, I just need an explanation on whats going on.
I would learn some cpp myself but honestly I really don't have the time.
Any help would be greatly appreciated.
Thanks
|
|
|
|
|
Ok...perhaps you could post the code here? Otherwise we cannot offer an explanation of it.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Cool, didnt get an email notifying me of a response.. sorry it took so long.
Heres the code. Its from a Microsoft sample app for creating a voice font, for SAPI.
/******************************************************************************
* mkvoice.cpp *
*-------------*
* This application assembles a simple voice font for the sample TTS engine.
*Copyright (c) Microsoft Corporation. All rights reserved.
*
******************************************************************************/
#include "stdafx.h"
#include <ttseng_i.c>
#include <direct.h>
int wmain(int argc, WCHAR* argv[])
{
USES_CONVERSION;
static const DWORD dwVersion = { 1 };
ULONG ulNumWords = 0;
HRESULT hr = S_OK;
//--- Check args
if( argc != 4 )
{
printf( "%s", "Usage: > mkvoice [[in]word list file] [[out]voice file] [voice name]\n" );
hr = E_INVALIDARG;
}
else
{
::CoInitialize( NULL );
//--- Open word list file and create output voice file
//--- _wfopen is not supported on Win9x, so use fopen.
FILE* hWordList = fopen( W2A(argv[1]), "r" );
FILE* hVoiceFile = fopen( W2A(argv[2]), "wb" );
if( hWordList && hVoiceFile )
{
//--- Write file version and leave space for word count
if( !fwrite( &dwVersion, sizeof(dwVersion), 1, hVoiceFile ) ||
fseek( hVoiceFile, 4, SEEK_CUR ) )
{
hr = E_FAIL;
}
//--- Get each entry
WCHAR WordFileName[MAX_PATH];
while( SUCCEEDED( hr ) && fgetws( WordFileName, MAX_PATH, hWordList ) )
{
ULONG ulTextLen = wcslen( WordFileName );
if( WordFileName[ulTextLen-1] == '\n' )
{
WordFileName[--ulTextLen] = NULL;
}
//--- Include NULL character when writing to the file
ulTextLen = (ulTextLen+1) * sizeof(WCHAR);
if( fwrite( &ulTextLen, sizeof(ulTextLen), 1, hVoiceFile ) &&
fwrite( WordFileName, ulTextLen, 1, hVoiceFile ) )
{
++ulNumWords;
//--- Open the wav data
ISpStream* pStream;
wcscat( WordFileName, L".wav" );
hr = SPBindToFile( WordFileName, SPFM_OPEN_READONLY, &pStream );
if( SUCCEEDED( hr ) )
{
CSpStreamFormat Fmt;
Fmt.AssignFormat(pStream);
if( Fmt.ComputeFormatEnum() == SPSF_11kHz16BitMono )
{
STATSTG Stat;
hr = pStream->Stat( &Stat, STATFLAG_NONAME );
ULONG ulNumBytes = Stat.cbSize.LowPart;
//--- Write the number of audio bytes
if( SUCCEEDED( hr ) &&
fwrite( &ulNumBytes, sizeof(ulNumBytes), 1, hVoiceFile ) )
{
BYTE* Buff = (BYTE*)alloca( ulNumBytes );
if( SUCCEEDED( hr = pStream->Read( Buff, ulNumBytes, NULL ) ) )
{
//--- Write the audio samples
if( !fwrite( Buff, 1, ulNumBytes, hVoiceFile ) )
{
hr = E_FAIL;
}
}
}
else
{
hr = E_FAIL;
}
}
else
{
printf( "Input file: %s has wrong wav format.", WordFileName );
}
pStream->Release();
}
}
else
{
hr = E_FAIL;
}
}
}
else
{
hr = E_FAIL;
}
//--- Write word count
if( SUCCEEDED( hr ) )
{
if( fseek( hVoiceFile, sizeof(dwVersion), SEEK_SET ) ||
!fwrite( &ulNumWords, sizeof(ulNumWords), 1, hVoiceFile ) )
{
hr = E_FAIL;
}
}
//--- Register the new voice file
// The section below shows how to programatically create a token for
// the new voice and set its attributes.
if( SUCCEEDED( hr ) )
{
CComPtr<ispobjecttoken> cpToken;
CComPtr<ispdatakey> cpDataKeyAttribs;
hr = SpCreateNewTokenEx(
SPCAT_VOICES,
argv[3],
&CLSID_SampleTTSEngine,
L"Sample TTS Voice",
0x409,
L"Sample TTS Voice",
&cpToken,
&cpDataKeyAttribs);
//--- Set additional attributes for searching and the path to the
// voice data file we just created.
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Gender", L"Male");
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Name", L"SampleTTSVoice");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Language", L"409");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Age", L"Adult");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Vendor", L"Microsoft");
}
//--- _wfullpath is not supported on Win9x, so use _fullpath.
CHAR szFullPath[MAX_PATH * 2];
if (SUCCEEDED(hr) && _fullpath(szFullPath, W2A(argv[2]), sizeof(szFullPath)/sizeof(szFullPath[0])) == NULL)
{
hr = SPERR_NOT_FOUND;
}
if (SUCCEEDED(hr))
{
USES_CONVERSION;
hr = cpToken->SetStringValue(L"VoiceData", A2W(szFullPath));
}
}
}
//--- Cleanup
if( hWordList )
{
fclose( hWordList );
}
if( hVoiceFile )
{
fclose( hVoiceFile );
}
::CoUninitialize();
}
return FAILED( hr );
}
|
|
|
|
|
if you want to learn C++, don't use this example !!!!
start with the basics, then start learnin at some libraries (Win32, MFC, ATL, ...), and only then, you could read some advanced examples like that.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I don't want to learn C++. I was simply asking if someone could point me in the right direction here as to what exactly this code is doing.
|
|
|
|
|
Basically i just want to change those five or six cpDataKeyAttribs...
Maybe I should just compile it, know any free C++ compilers?
|
|
|
|
|
search for gcc and g++ (linux based, but maybe ported to windows plateforms)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
If I say
this.CreateGraphics();
What's "this"?
|
|
|
|
|
"this" is a key word to refer to the currently instantiated class that the method is in so if you had:
<br />
public ref class FrmMyCoolForm : public System::Windows::Forms::Form<br />
{<br />
public:<br />
FrmMyCoolForm(void)<br />
{<br />
this->Visible = false;<br />
}<br />
}<br />
You would be changing the visiblility of the object that the method was called from.
(Probably not close to a textbook definition but hope it makes sense)
EDIT: Here is a definition C++ keyword used in a member function to point at the object currently being operated on.
|
|
|
|
|
THanks- I inderstad that. I'm referring to the CreateGraphics.
CreateGraphics is a "method" when a WHAT is instantiate.
int x;
this->Foo() == x.Foo() //OK
this.CreateGraphics() // What's "this"? in THIS case
Is it Graphics g?
|
|
|
|
|