Jump to content
Xtreme .Net Talk

dynamic_sysop

Leaders
  • Posts

    1044
  • Joined

  • Last visited

Everything posted by dynamic_sysop

  1. are you trying to set the image on a different form than the one you are on? eg: trying to set Form1's background from Form2?
  2. so you don't think it's a bit harsh saying ' Someone should kick them off. ' ? speaking from experience most forum leaders got to that status through many hours of their own time dedicated to helping other people for no cost. i personally cannot get on the forums as much as i'd like & had a very quiet time for a long while. The reason for my quite time of not posting was ... trying to get my father-in-law better from terminal lung cancer, then as he got diagnosed as on the way to recovery, losing him to the illness. I don't need to advertise this, i'm sure other people going through a terrible time in their ' REAL ' personal lives would not appreciate being ' booted ' off a status they worked hard to get just because they didn't post a message for sometime. Most people will be glad that there are forum leaders ( who pop in & out of the forum even when not posting messages ) Seems a bit of a kick in the teeth trying to get rid of the people that have helped so many others for such a minor reason :confused:
  3. use System.Diagnostics.Process.Start eg: [color=blue]Private Sub[/color] SomeSub() [color=blue] Dim[/color] od [color=blue]As New[/color] OpenFileDialog [color=blue]With[/color] od .Filter = "Applications (*.exe)|*.exe" [color=blue]End With[/color] [color=blue]If[/color] od.ShowDialog = DialogResult.OK [color=blue]Then[/color] System.Diagnostics.Process.Start(od.FileName) [color=green]'/// od.FileName being the path of the .exe[/color] [color=blue]End If[/color] [color=blue]End Sub[/color]
  4. you seem to have a lot of quotes on the realplayer path , this line ... did you know that you can specify a file path with either an @ symbol or double back slashes \\ , eg: Public gstrRealPlayerPath As String = @"C:\Program Files\Real\RealPlayer\realplay.exe" or Public gstrRealPlayerPath As String = "C:\\Program Files\\Real\\RealPlayer\\realplay.exe" it may be that the extra "" are causing a problem.
  5. Hi folks, long time since i done this http://www.xtremedotnettalk.com/x_images/images/smilies/frown.gif anyway i've knocked together a little example that allows you to list the files in a .CAB file ( it can be built upon to allow extraction etc... ) the class to read the cab ... '/// at very top of Class / Form... Imports System.Runtime.InteropServices Public Class CAB #Region "API / DELEGATES" <StructLayout(LayoutKind.Sequential)> _ Public Structure FILE_IN_CABINET_INFO Public NameInCabinet As IntPtr Public FileSize As Int32 Public Win32Error As Int32 Public DosDate As Int16 Public DosTime As Int16 Public DosAttribs As Int16 <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _ Public FullTargetName As String End Structure Public Delegate Function PSP_FILE_CALLBACK_A(ByVal Context As Int32, ByVal Notification As Int32, ByVal Param1 As IntPtr, ByVal Param2 As IntPtr) As Int32 Private Declare Function SetupIterateCabinet Lib "setupapi.dll" Alias "SetupIterateCabinetA" (ByVal CabinetFile As String, ByVal Reserved As Int32, ByVal MsgHandler As PSP_FILE_CALLBACK_A, ByVal Context As Int32) As Int32 Private Declare Function DosDateTimeToFileTime Lib "kernel32.dll" (ByVal wFatDate As Int16, ByVal wFatTime As Int16, ByRef lpFileTime As FILETIME) As Int32 <StructLayout(LayoutKind.Sequential)> _ Private Structure FILETIME '/// should be a Low & High part ( 2 x Int32 ) but 1 x Int64 works perfect with Date.FromFileTime Public dwLowDateTime As Int64 End Structure Private Const SPFILENOTIFY_CABINETINFO As Int32 = &H10 Private Const SPFILENOTIFY_FILEEXTRACTED As Int32 = &H13 Private Const SPFILENOTIFY_FILEINCABINET As Int32 = &H11 Private Const SPFILENOTIFY_NEEDNEWCABINET As Int32 = &H12 Private Const FILEOP_SKIP As Int32 = 2 #End Region '/// HERE i open a CAB file to read it's contents... Public Sub New(ByVal cabpath As String) Dim cb As New PSP_FILE_CALLBACK_A(AddressOf PSP_FILE_CALLBACK) SetupIterateCabinet(cabpath, 0, cb, 0) End Sub Private Function PSP_FILE_CALLBACK(ByVal Context As Int32, ByVal Notification As Int32, ByVal Param1 As IntPtr, ByVal Param2 As IntPtr) As Int32 '/// from msdn's C++ description @ [url="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/setupapi/setup/psp_file_callback.asp"]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/setupapi/setup/psp_file_callback.asp[/url] '/// my interpretation... Dim FILEINCABINET As Int32 = 0 Select Case Notification Case SPFILENOTIFY_FILEINCABINET '/// we've found a file in the CAB [img=http://www.xtremedotnettalk.com/x_images/images/smilies/smile.gif] FILEINCABINET = PSP_FILEFOUND_CALLBACK(Context, Notification, Param1, Param2) '/// here we can also extract the files from the CAB. '/// but we'll call PSP_FILEFOUND_CALLBACK for now. End Select Return FILEINCABINET End Function Private Function PSP_FILEFOUND_CALLBACK(ByVal Context As Int32, ByVal Notification As Int32, ByVal Param1 As IntPtr, ByVal Param2 As IntPtr) As Int32 Dim FILEFOUND As Int32 Select Case Context Case 0 Dim f_in_cab As FILE_IN_CABINET_INFO = DirectCast(Marshal.PtrToStructure(Param1, GetType(FILE_IN_CABINET_INFO)), FILE_IN_CABINET_INFO) Dim frm As Form1 = DirectCast(Form.ActiveForm, Form1) '/// convert the IntPtr value of the filename to a readable string & add to a ListView... Dim lvi As New ListViewItem(Marshal.PtrToStringAnsi(f_in_cab.NameInCabinet)) '/// the FILETIME should be 2 Int32's, but to get the resulting long value required i made it one Int64 [img=http://www.xtremedotnettalk.com/x_images/images/smilies/smile.gif] Dim ft As FILETIME DosDateTimeToFileTime(f_in_cab.DosDate, f_in_cab.DosTime, ft) Dim d As Date = Date.FromFileTime(ft.dwLowDateTime) lvi.SubItems.Add(New ListViewItem.ListViewSubItem(lvi, d.ToLongDateString & " " & d.ToLongTimeString)) frm.ListView1.Items.Add(lvi) FILEFOUND = FILEOP_SKIP End Select '/// must Return FILEFOUND to continue enumerating the files in the cab. Return FILEFOUND End Function End Class the way to use it, from a Form ... Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim OD As New OpenFileDialog With OD .Filter = "CAB files|*.CAB" .RestoreDirectory = True End With If OD.ShowDialog = DialogResult.OK Then ListView1.Columns(0).Text = OD.FileName Dim cabinet As New CAB(OD.FileName) End If End Sub i've included a zipped example source code http://www.xtremedotnettalk.com/x_images/images/smilies/smile.gif CABFiles_in_NET.zip
  6. you could always use the SHFileOperation API mate http://www.xtremedotnettalk.com/images/smilies/wink.gif you can specify wildcards ( eg: *.jpg , *.bmp , *.whatever ) to allow only certain files to be copied / moved / deleted. here's a quick example... Public Structure SHFILEOPSTRUCT Public hWnd As Integer Public wFunc As Integer Public pFrom As String Public pTo As String Public fFlags As Integer Public fAborted As Integer Public hNameMaps As Integer Public sProgress As String End Structure Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer Private Const FO_COPY As Int32 = &H2 Private Const FO_DELETE As Int32 = &H3 Private Const FO_MOVE As Int32 = &H1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim shStructure As New SHFILEOPSTRUCT '///here i specify the wildcard *.jpg ... Dim currentpath As String = "C:\Documents and Settings\den\My Documents\My Pictures\imgs\*.jpg" '/// images in folder to copy '/// new path to COPY the images to ( jpg only in this case ) Dim newpath As String = "E:\imgs\" '/// new path With shStructure .wFunc = FO_COPY .pFrom = currentpath .pTo = newpath End With SHFileOperation(shStructure) End Sub hope it helps :)
  7. the sdk for quicktime can be found at developer.apple.com here's some links to the appropriate pages ... SDK ... http://developer.apple.com/sdk/ Documentation of SDK... http://developer.apple.com/documentation/QuickTime/RM/Fundamentals/QTOverview/QTOverview_Document/chapter_1000_section_3.html Alphabetical list of API's... http://developer.apple.com/documentation/QuickTime/APIREF/AlphabeticalIndexofFunctions.htm they can be used in all the main coding languages :)
  8. you could always set the style of the box to ES_NUMBER , but you must handle the WM_PASTE message via a simple subclass , eg: Private Const GWL_STYLE As Int32 = -16 Private Const ES_NUMBER As Int32 = &H2000I Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Int32) As Int32 Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Int32, ByVal dwNewLong As Int32) As Int32 Private numbertext As NumericText Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '/// to handle the case of someone trying to paste none - numeric text ... numbertext = New NumericText(TextBox1.Handle) '/// set the style of the textbox to numeric only ( but unfortunatly it still accepts pasting of text , hence the subclassing ) Dim style As Int32 = GetWindowLong(TextBox1.Handle, GWL_STYLE) If style > 0 Then style += ES_NUMBER SetWindowLong(TextBox1.Handle, GWL_STYLE, style) End If End Sub End Class Public Class NumericText Inherits NativeWindow Private Const WM_PASTE As Int32 = &H302 Public Sub New(ByVal hwnd As IntPtr) MyBase.AssignHandle(hwnd) End Sub Protected Overrides Sub WndProc(ByRef m As Message) Select Case m.Msg Case WM_PASTE '/// prevent the pasting of none-numerics Case Else MyBase.WndProc(m) End Select End Sub End Class
  9. you need to use the Document.documentElement.InnerHtml / Document.documentElement.OuterHtml not the body.outerhtml
  10. you need to declare myUri as a new URI ( you can also specify a url as a string ) eg: [font=Courier New][size=2][color=#008000]'/// declare myUri ( note : you can also use a string as the uri in your request , eg: HttpWebRequest.Create("http://msn.co.uk/") )[/color][/size][/font] [font=Courier New][size=2][color=#0000ff]Dim[/color][/size][size=2] myUri [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]New[/color][/size][size=2] Uri([url="http://msn.co.uk/"]http://msn.co.uk/[/url])[/size][/font] [font=Courier New][size=2][color=#008000]'/// make a request to the URI ...[/color][/size][/font] [font=Courier New][size=2][color=#0000ff]Dim[/color][/size][size=2] request [/size][size=2][color=#0000ff]As[/color][/size][size=2] WebRequest = [/size][size=2][color=#0000ff]DirectCast[/color][/size][size=2](WebRequest.Create(myUri), WebRequest)[/size][/font] [font=Courier New][size=2][color=#0000ff]Dim[/color][/size][size=2] response [/size][size=2][color=#0000ff]As[/color][/size][size=2] WebResponse = request.GetResponse[/size][/font] [font=Courier New][size=2]MessageBox.Show(response.Headers.ToString)[/size][/font]
  11. try PBM_SETMARQUEE & PBS_MARQUEE first you need to extend the style of the progressbar if you are familiar with GetWindowLong / SetWindowLong. then do a SendMessage(Handle_To_ProgressBar_Here PBM_SETMARQUEE , True , Time_in_MilliSeconds_Here ) from Msdn ...
  12. check this link out, it has an example of what you want maybe ... How to set the background color of a DateTimePicker control.
  13. To start a process and keep track of the process, you need to declare a new instance of it , eg: Dim info As New ProcessStartInfo("iexplore.exe") info.UseShellExecute = True info.Arguments = "http://msn.co.uk" '/// carry out any additional arguments, eg: navigate to a webpage in this case Dim proc As New Process '/// create a new instance of the Process Class proc.StartInfo = info proc.Start() if you are using a Console Application and it's dissapearing after a process has started, you can add ' Console.ReadLine() ' after the code that starts the process. ( if you wish to keep the Console window open that is )
  14. you can use ExtractIconEx , here's a quick example i knocked together for you ... Private Declare Function ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Int32, ByRef phiconLarge As IntPtr, ByRef phiconSmall As IntPtr, ByVal nIcons As Int32) As Int32 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '/// assuming you have a ListView , set to SmallIcon View & an ImageList tied to it's smallimagelist Dim path As String = "C:\Program Files\IconForge7\LEAVES.ICL" '/// path to a valid .ICL file goes here. '/// to retreive the count of icons , use path , then index set to -1 , then 2 IntPtr.Zero's , then a 0 ... Dim index As Int32 = ExtractIconEx(path, -1, IntPtr.Zero, IntPtr.Zero, 0) '/// if the count is greater than ' 0 ' ( meaning no icons ) ... If index > 0 Then For x As Int32 = 0 To index - 1 Dim icoLarge As IntPtr Dim icoSmall As IntPtr ExtractIconEx(path, x, icoLarge, icoSmall, 1) '/// lets add the small icon retreived from the index 'x ' '/// if you wanted to use LargeIcon view on your listview / wanted the large icons for any purpose , use icoLarge. If Not icoSmall.Equals(IntPtr.Zero) Then Dim i As Icon = Icon.FromHandle(icoSmall) ImageList1.Images.Add(i) Dim lvi As New ListViewItem("", x) ListView1.Items.Add(lvi) End If '/// move on to the next indexed icon in the .ICL file Next End If End Sub
  15. there's a default way of translating color to html you know? ie: the ColorTranslator class ... Dim cl As Color = Color.Red MessageBox.Show(ColorTranslator.ToHtml(cl)) to reverse it use ColorTranslator.FromHtml
  16. i think that according to this article It's Time for VB6+. it looks like it won't be much good after XP. a quote from the article ...
  17. how are you specifying your SendMessage Function? because you can customize it pretty much to suit your needs, thus making it do it's job of working fast.
  18. well , the 3rd parameter should be a zero , not -1 so try ... SendMessage(ComboBox1.Handle, CB_ADDSTRING, [color=Red][b]0[/b][/color], "Some Text") '/// note i've replaced the [b]-1[/b] with [b]0[/b]
  19. use the Split function of the String Class , eg: Dim NameSurname As String = "John Doe" '/// use Split , the Space being the divider Dim FirstName As String = NameSurname.Split(" ")(0) Dim LastName As String = NameSurname.Split(" ")(1) MessageBox.Show("the first name is " & FirstName & Environment.Newline & "the last name is " & LastName)
  20. ideally you shouldn't be using Winsock in .NET ( whether it be vb.net , c# or c++ ) , take a look at the System.Net.Socket Class. here's a quick example of connecting to an address , sending a GET / request and handling the Receiving of the data . // reference these near the top of your form's code window ... using namespace System::Net; using namespace System::Net::Sockets; private: Socket * socket; // this will do the Sending and Receiving private: Byte buffer[]; // this will Receive any Data ( hold the data ) private: void button1_Click(System::Object * sender, System::EventArgs * e) { IPHostEntry * host = Dns::Resolve("msn.com"); IPAddress * address = host->AddressList[0]; IPEndPoint * point = new IPEndPoint(address , 80); socket = new Socket(AddressFamily::InterNetwork , SocketType::Stream , ProtocolType::Tcp); socket->BeginConnect(point, new AsyncCallback(this,Connected), socket); } private: void Connected(IAsyncResult * ar) { if(ar->IsCompleted) { String * str = S"GET /\r\n"; // lets send a GET / message to retrieve the content of msn.com's address. Byte data[] = System::Text::Encoding::ASCII->GetBytes(str); // first we must convert it to a byte array. socket->Send(data,data->Length,SocketFlags::None); buffer = new Byte[(int)SocketFlags::Partial]; socket->BeginReceive(buffer,0,buffer->Length,SocketFlags::Partial, new AsyncCallback(this,Receive), socket); } } private: void Receive(IAsyncResult * ar) { int x = socket->EndReceive(ar); if(x > 0) { richTextBox1->AppendText(System::Text::Encoding::ASCII->GetString(buffer)); socket->BeginReceive(buffer,0,buffer->Length,SocketFlags::Partial, new AsyncCallback(this,Receive), socket); } } for more info on the Socket Class check this msdn article ... Link to Socket Class article hope it helps you on your way :cool:
  21. use Environment.NewLine , eg: MessageBox.Show("some stuff " & Environment.NewLine & "more stuff")
  22. The .NET Framework uses Api's within it's self anyway , they are internal ( inside most of the .net dlls ) , you will have to use Api ( whether it be adding them in to a form , or using the internal ( private ) api's via Type.InvokeMethod. anyway the Api way you will want to set the Privilages to allow you to shut down the pc ( if running an NT based system , ie: Windows XP ) , try this ... Private Declare Function GetCurrentProcess Lib "kernel32.dll" () As IntPtr Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As IntPtr, ByVal DesiredAccess As Int32, ByRef TokenHandle As IntPtr) As Int32 Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, ByRef lpLuid As LUID) As Int32 Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As IntPtr, ByVal DisableAllPrivileges As Int32, ByRef NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Int32, ByRef PreviousState As TOKEN_PRIVILEGES, ByRef ReturnLength As Int32) As Int32 Private Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Int32, ByVal dwReserved As Int32) As Int32 Private Const EWX_FORCE As Int32 = 4 Private Const EWX_SHUTDOWN As Int32 = 1 Private Const EWX_REBOOT As Int32 = 2 Private Const EWX_LOGOFF As Int32 = 0 Public Structure LUID Dim LowPart As Int32 Dim HighPart As Int32 End Structure Public Structure TOKEN_PRIVILEGES Public PrivilegeCount As Integer Public Privileges As LUID Public Attributes As Int32 End Structure Private Sub btn_ShutDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ShutDown.Click ShutDown() End Sub Private Sub btn_Restart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Restart.Click Restart() End Sub Private Sub Restart() If MessageBox.Show("Would you like to re-boot the system", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then Dim platform As New PlatformID Select Case Environment.OSVersion.Platform Case PlatformID.Win32NT Dim token As TOKEN_PRIVILEGES Dim blank_token As TOKEN_PRIVILEGES Dim token_handle As IntPtr Dim uid As LUID Dim ret_length As Integer Dim ptr As IntPtr = GetCurrentProcess() '/// get the process handle OpenProcessToken(ptr, &H20 Or &H8, token_handle) LookupPrivilegeValue("", "SeShutdownPrivilege", uid) token.PrivilegeCount = 1 token.Privileges = uid token.Attributes = &H2 AdjustTokenPrivileges(token_handle, False, token, System.Runtime.InteropServices.Marshal.SizeOf(blan k_token), blank_token, ret_length) ExitWindowsEx(EWX_LOGOFF Or EWX_FORCE Or EWX_REBOOT, &HFFFF) Case Else ExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE Or EWX_REBOOT, &HFFFF) End Select End If End Sub Private Sub ShutDown() If MessageBox.Show("Would you like to shut down the system", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then Dim platform As New PlatformID Select Case Environment.OSVersion.Platform Case PlatformID.Win32NT Dim token As TOKEN_PRIVILEGES Dim blank_token As TOKEN_PRIVILEGES Dim token_handle As IntPtr Dim uid As LUID Dim ret_length As Integer Dim ptr As IntPtr = GetCurrentProcess() '/// get the process handle OpenProcessToken(ptr, &H20 Or &H8, token_handle) LookupPrivilegeValue("", "SeShutdownPrivilege", uid) token.PrivilegeCount = 1 token.Privileges = uid token.Attributes = &H2 AdjustTokenPrivileges(token_handle, 0, token, System.Runtime.InteropServices.Marshal.SizeOf(blan k_token), blank_token, ret_length) ExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE, &HFFFF) Case Else ExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE, &HFFFF) End Select End If End Sub
  23. they run fine for me :cool:
  24. Context.Items["datatable"] is an object , in this case a DataTable by the look of it , so you are casting the object to a DataTable. basically it's not context = context , it's context = datatable
  25. Specify Encoding.ASCII when opening the Stream , eg: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim pathToUtfFile As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\\Text\\IUserNotification.txt" Dim sreader As New StreamReader(pathToUtfFile, Encoding.ASCII) While Not sreader.Peek = -1 Console.WriteLine(sreader.ReadLine) End While sreader.Close() End Sub
×
×
  • Create New...