|
I don't think this message was meant for me.
Veni, vidi, abiit domum
|
|
|
|
|
Yes, RICHARD it wasn't, it was for SUPERCODER2014. And as u said I posted on author's forum too, I think that might help
|
|
|
|
|
And my message was not directed at you, but SuperCoder2014.
Veni, vidi, abiit domum
|
|
|
|
|
Ohh, sorry my bad, u know that I posted the problem, right? I changed name from number to myth1990.
Sorry for misunderstanding
|
|
|
|
|
Hello!
I have following problem. I want to create a application, which is using Netsh. I have created following code:
private: System::Void button1_Click( System::Object ^ sender, System::EventArgs ^ e ) {
Process ^ mojProces = gcnew Process();
ProcessStartInfo ^ startInfo = gcnew ProcessStartInfo( "cmd.exe" );
startInfo->Verb = "runas";
startInfo->Arguments =( "Administrator /c \"netsh wlan start hostednetwork\" " );
startInfo->UseShellExecute = false;
startInfo->CreateNoWindow = true;
startInfo->RedirectStandardOutput = true;
startInfo->RedirectStandardInput = true;
info->Text = "Sieć została uruchomiona.";
mojProces->StartInfo = startInfo;
mojProces->Start();
StreamReader ^ wynik = mojProces->StandardOutput;
String ^ wynik_konsoli = wynik->ReadToEnd();
wynik_wysw->Text = wynik_konsoli;
mojProces->WaitForExit();
mojProces->Close();
Now I would like to redirect output of CMD, but there is following problem. When I set UseShellExecute=false, I cannot run CMD with administrator privileges, which is required to use Netsh. But when I set true I cannot redirect output. Could you please help, how can I solve this problem? Thank you in advance!
|
|
|
|
|
|
camillo87 wrote: Could you please help, how can I solve this problem? You might also try this forum.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
hi there
I would appreciate if someone could tell me how can I read character by character from a file?
I did some research about it but there weren't work in mine for example:
it couldn't verified infile although i use fstream library or is.get none of them working
char singlecharacter;
int singleCharacter ;
ifstream file ("vurudi");
file.is_open() ;
infile.get(singlecharacter);
|
|
|
|
|
Maybe this[^] link will help.
|
|
|
|
|
tnx for your replay.
as I said I used the code which I mention before from this link but it didnt work
|
|
|
|
|
You are going to have to get more specific on what's not working, are you able to open the file? Posting the whole program would probably help.
|
|
|
|
|
|
Just put the file.get into a while statement.
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char singlecharacter ;
ifstream file ("vurudi.txt");
file.is_open() ;
while(file.get(singlecharacter))
{
cout<<singlecharacter;
}
file.close();
cout<<"\n\n\n";
return 0;
}
|
|
|
|
|
There are a number of ways to do this depending on your preference and setup of C++ program
Using standard windows API:
HANDLE Handle;
char Ch;
unsigned long Li;
Handle = CreateFile("c:\\yourfile.txt",
GENERIC_READ, 0, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
if (Handle != INVALID_HANDLE_VALUE){
ReadFile(Handle, &Ch, 1, &Li, 0);
}
CloseHandle(Handle);
Using the standard ifstream unit:
#include <fstream>
char Ch;
ifstream myFile;
myFile.open("c:\\yourfile.txt");
if (myFile.is_open()) {
myFile.read(Ch, sizeof(Ch));
}
myFile.Close();
Using the standard MFC CFile assuming you are using MFC:
UINT nActual = 0;
char Ch;
CFile myFile;
if ( myFile.Open( _T("c:\\yourfile.txt"), CFile::modeRead | CFile::shareDenyWrite ) )
{
nActual = myFile.Read( Ch, sizeof(Ch) );
}
myFile.Close();
|
|
|
|
|
|
MalDrHoop wrote: I have a C program I just posted some minutes ago.
Not that I can see.
|
|
|
|
|
Thank you for looking it over. I dont know why it isnt giving me the desired results.
|
|
|
|
|
Please give this[^] a read, as I have no idea what you have or want.
|
|
|
|
|
I have skimmed through those. The problem is, I can't find a problem with my program. Idk what is going on unless I haven't made a mistake and just misunderstood the professor. I just know that my program fails after many iterations and it shouldn't take many to achieve the desired result.
Thank you for your time anyways
|
|
|
|
|
MalDrHoop wrote: The problem is, I can't find a problem with my program
You haven't asked a specific question.
You haven't posted any code.
And possibly worst of all, you used text speak.
MalDrHoop wrote: I have skimmed through those.
Apparently not well enough.
|
|
|
|
|
Actually, sir, you apparently did not read my original question. In it I asked for someone to go to where I had posted a question and check it out.
|
|
|
|
|
MalDrHoop wrote: where I had posted a question
Please point this out to me in your original post, the where part I mean. It is customary to post the code here.
|
|
|
|
|
I am new to these discussion boards. This is my first one. I thought questions were posted under the designated questions area where there is a dropdown box in the top right corner next to your username. Whenever you go to someones profile there is an option to look at their questions and answers, etc. I added a direct link.
|
|
|
|
|
|
MalDrHoop wrote: This would have been as simple as clicking on my name
No, it would have been simple if you posted the code here. Why would I click on your name, how is your name relevant to anything c or c++ related? [Edit] And you're cross posting?
|
|
|
|