Jump to content
Xtreme .Net Talk

jorge

Avatar/Signature
  • Posts

    240
  • Joined

  • Last visited

Everything posted by jorge

  1. this still leave the problem of the textbox that runs out of space!
  2. thanx i'll ive it a go
  3. maybe i'll go for a rtf, i do'nt think it has a limit. becouse i ahve no idea what a stringbuilder is.
  4. ok now knowing what the problem was that it waits for input if there is none i fixed it by adding it to a thread :) but now i hit a new problem... when the textbox's max lenght is reached no text can be appended! so how can i remove some text from the top to make the new text fit?
  5. hmmz no one seems to know... o well pitty
  6. interface to cmd.exe Hey all, I'm trying to start and Application that opens the cmd.exe (hidden) and write and read from it. so far I seem to have fingered out the writing part! but reading the output and also the code to hide it doesn't work. can someone help with this (include is my test project I'm using for this) thanx in advance ApacheCompiler.zip
  7. Is the a way to convert 'Times New Roman' 'Arial' ... Into the path of the font? e.g. c:\windows\fonts\times.ttf? (i'm trying to do it in vb.net) thanx in advance
  8. Cool this works fine :) thanx a lot, now it's a normal string :p
  9. Thanx, i'll play with this a bit
  10. Ok how would i convert a string to a byte array?
  11. yeah thanx it works like a charm No to fix the decrypt thing and am done :D , the decrypt thing can't be that ahard lol
  12. To keep it ontop also set me.topmost = true but to make other windows resize around it i have no ideas sry
  13. This is some very basic code, you need to tweak it your self but do: make a new vb.net project place a button on the form and add Me.ShowInTaskbar = False Me.FormBorderStyle = FormBorderStyle.None Me.Width = 200 Me.Height = Screen.PrimaryScreen.WorkingArea.Height Me.Top = 0 Me.Left = Screen.PrimaryScreen.WorkingArea.Width - Me.Width it will doc to the left side of the primary screen. Hope this helps a bit
  14. Hmmz have got the encrypt funtion to work, not decrypt jet, still crashes, but i notice something every thime i encrypt i get something else as result :/ any ideas?
  15. Ok been playing with it some more but i'm having problem i've attachd my code Encrypt("hello") will retunr system.byte() not the encrypted form of hello thanx in advance crypto.vb.txt
  16. Hey, Any one have and easy to use encryption class? or a peice of code to do it? Cause i'm transfering a user+pass over the network(user:pass@command) but it can easyly be read and that i don't wan't. thanx in advance
  17. k works now, thanx
  18. Well i get a error , and do'nt know what it is and there is nothing on google: here is the code: Imports System Imports System.Runtime.InteropServices Namespace CM2 'Since the .NET Framework interface and coclass have to behave as 'COM objects, we have to give them guids. <Guid("")> Public Interface IManagedInterface Function PrintHi(ByVal Name As String) As Integer End Interface <Guid("")> Public Class InterfaceImplementation Implements IManagedInterface Public Function PrintHi(ByVal name As String) As Integer Console.WriteLine("Hello, {0}!", name) Return 33 End Function End Class End Namespace the error is on: Implements IManagedInterface and the error msg is: COM.vb(15) : error BC30149: 'CM2.InterfaceImplementation' must implement 'Function PrintHi(Name As String) As Integer' for interface 'CM2.IManagedInterface'. any one had something like this befor?
  19. console.write does work, the output is displayed by the server, now i only need to get imput, anyone got and idea?
  20. is it possible to create a cgi program in vb.net to use with a server? i try making a console application and then doing console.readline, but it is always empty.
  21. jorge

    Web Server

    No, give error on teh from1 thing's, but i suspected that, and i removed them but it still gives a error on: sBuffer = sBuffer + "Content-Length: " + iTotBytes + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" Dim bSendData As Byte = Encoding.ASCII.GetBytes(sBuffer)
  22. jorge

    Web Server

    That would work, but i want to modify the server code a bit, so then that won't work anymore :( Here is what i have converted: Imports System Imports System.IO Imports System.Net Imports System.Net.Sockets Imports System.Text Imports System.Threading Namespace WebServer Class WebServer Private sMyWebServerRoot As String Private mySocket As Socket Public Sub New(ByVal s As Socket, ByVal Location As String) mySocket = s sMyWebServerRoot = Location + "\" End Sub Private Function GetMimeType(ByVal fileName As String) As String If fileName.EndsWith(".htm") OrElse fileName.EndsWith(".html") Then Return "text/html" Else If fileName.EndsWith(".jpg") OrElse fileName.EndsWith(".jpeg") Then Return "image/jpeg" Else If fileName.EndsWith(".gif") Then Return "image/gif" Else If fileName.EndsWith(".txt") Then Return "text/plain" Else Return "application/octet-stream" End If End If End If End If End Function Private Sub SendHeader(ByVal sHttpVersion As String, ByVal sMIMEHeader As String, ByVal iTotBytes As Integer, ByVal sStatusCode As String) Dim sBuffer As String = "" If sMIMEHeader.Length = 0 Then sMIMEHeader = "text/html" End If sBuffer = sBuffer + sHttpVersion + sStatusCode + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" sBuffer = sBuffer + "Server: MyWebServer-b" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" sBuffer = sBuffer + "Content-Type: " + sMIMEHeader + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" sBuffer = sBuffer + "Accept-Ranges: bytes" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" sBuffer = sBuffer + "Content-Length: " + iTotBytes + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "" Dim bSendData As Byte = Encoding.ASCII.GetBytes(sBuffer) SendToBrowser(bSendData) End Sub Private Sub SendToBrowser(ByVal sData As String) SendToBrowser(Encoding.ASCII.GetBytes(sData)) End Sub Private Sub SendToBrowser(ByVal bSendData() As Byte) Dim numBytes As Integer = 0 Try If mySocket.Connected Then If (numBytes = mySocket.Send(bSendData, bSendData.Length, 0)) = -1 Then Form1.WriteToConsole("Socket Error cannot Send Packet" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "") Else Form1.WriteToConsole("No. of bytes send " + numBytes + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "") End If Else Form1.WriteToConsole("Connection Dropped....") End If Catch e As Exception Form1.WriteToConsole("Error Occurred : " + e + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "") End Try End Sub Public Sub HandleConnection() Dim iStartPos As Integer = 0 Dim sRequest As String Dim sDirName As String Dim sRequestedFile As String Dim sErrorMessage As String Dim sLocalDir As String Dim sPhysicalFilePath As String = "" Dim bReceive(1024) As Byte Dim i As Integer = mySocket.Receive(bReceive, bReceive.Length, 0) Dim sBuffer As String = Encoding.ASCII.GetString(bReceive) If Not (sBuffer.Substring(0, 3) = "GET") Then Form1.WriteToConsole("Only Get Method is supported.." + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "") mySocket.Close() Return End If iStartPos = sBuffer.IndexOf("HTTP", 1) Dim sHttpVersion As String = sBuffer.Substring(iStartPos, 8) sRequest = sBuffer.Substring(0, iStartPos - 1) Form1.WriteToConsole("File Requested : " + sRequest + "" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "") sRequest.Replace("\", "/") If (sRequest.IndexOf(".") < 1) AndAlso (Not sRequest.EndsWith("/")) Then sRequest = sRequest + "/" End If iStartPos = sRequest.LastIndexOf("/") + 1 sRequestedFile = sRequest.Substring(iStartPos) sDirName = sRequest.Substring(sRequest.IndexOf("/"), sRequest.LastIndexOf("/") - 3) sLocalDir = sMyWebServerRoot If sRequestedFile.Length = 0 Then If sRequestedFile = "" Then sRequestedFile = "index.htm" End If End If Dim sMimeType As String = GetMimeType(sRequestedFile) sPhysicalFilePath = sLocalDir + sDirName + sRequestedFile If File.Exists(sPhysicalFilePath) = False Then sErrorMessage = "<H2>404 Error! File Does Not Exist...</H2>" SendHeader(sHttpVersion, "", sErrorMessage.Length, " 404 Not Found") SendToBrowser(sErrorMessage) Form1.WriteToConsole("File Not found" + Microsoft.VisualBasic.Chr(13) + "" + Microsoft.VisualBasic.Chr(10) + "") Else Dim fs As FileStream = New FileStream (sPhysicalFilePath, FileMode.Open, FileAccess.Read, FileShare.Read) Dim reader As BinaryReader = New BinaryReader (fs) Dim bytes(fs.Length) As Byte bytes = reader.ReadBytes(CType(fs.Length, Integer)) Dim totbytes As Integer = CType(fs.Length, Integer) reader.Close() fs.Close() SendHeader(sHttpVersion, sMimeType, totbytes, " 200 OK") SendToBrowser(bytes) End If mySocket.Close() End Sub End Class End Namespace but that doesnt work :confused:
  23. jorge

    Web Server

    no one knows??
  24. jorge

    Web Server

    webserver(c# code, but need vb.net) Hey all, i am trying to include a small webserver in one of my application, so far i have found a very nice example, but it is in c# i've been trying to convert it, but i always hit the same error(to many to sum up) i'm talking about: http://www.codeproject.com/Purgatory/webservergui.asp if any one has converted it or know a vb.net very. can you post a link? Thanx in advance
×
×
  • Create New...