|
9132
|
Sistemas Operativos / Windows / Re: Cambiar las rutas de varios directorios para congelar windows
|
en: 30 Abril 2013, 18:12 pm
|
¿Mover las carpetas del sistema a otra partición (menos la de "Windows") y especificar esa partición como partición de sistema mediante el registro?, ese debe ser el sueño de todo lammer que hace virus para joder el el arranque del SO xD.
Puedes modificar la partición actual del sistema con "BCDEdit" o con "Easy BCD" sin ir más lejos, puedes hacer todos los cambios relevantes que quieras, pero lo que planteas no puedes hacerlo y no creo que nunca vaya a ser porislbe en un futuro.
· Las carpetas del sistema, por algo se llaman "de sistema".
· Los perfiles de usuario se generan en la partición de sistema, no en una partición activa.
· Las variables de entorno de Windows apuntan a directorios de la partición de sistema (APPDATA LOCALAPPDATA USERPROFILE SYSTEMROOT, etc...), y hasta donde yo sé no puedes modificar sus localizaciones (sólamente la localización de la avriable TEMP), y son las variables en las que se basan TODOS los programas, así que un programa que ejecutes en "D:" no va a buscar en esa partición, ni tampoco va a crear los archivos necesarios en esa partición.
· Todas las carpetas como "Escritorio" "mi música" "documentos" tienen su ruta especificada en el regedit así que si las mueves la cagas, aunque obviamente puedes cambiar las rutas especificadas en el regedit, vale, pero la idea es que si se modifican las rutas esas rutas sigan apuntando a un directorio de la partición de sistema.
· Los programas suelen guardar sus configuración en la ruta "...\roaming" de la partición del sistema.
· Existen unas dll's y archivos compartidos por el sistema en la ruta "\...\program files\common files\...", que están en la partición del sistema, no en la partición activa, así que eso daría como resultado un montón de claves inválidas (que podrías ver al usar ccleaner por ejemplo), claves que deberías editar las rutas hacia esos archivos compartidos en el regedit.
· También hay programas necesarios por Windows en la carpeta Program files (y x86), con que le heches un ojo sabrás cuales son.
· La carpeta programdata contiene información vital quizás no para el inicio dle SO, pero si para su uso, archivos temporales de caché de Windows, accesos directos del menú inicio, la caché de imágenes, etc, así como las configuraciones de los programas instalados, aunque los instales en otra partición. y aunque consiguieras mover esta carpeta (que no puedes), Windows depende de ella así que la intentaría generar en la partición del SISTEMA, igual que todas las demás carpetas que quieres mover, pero eso no pasará ni en el mejor de los casos, lo que pasaría es que no podrías arrancar el SO si mueves todas esas carpetas, diréctamente te saldria reparación del sistema.
· Muchos de los archivos que se encuentran en las distintas carpetas que quieres mover, estarán en uso por el sistema operativo así que no podrás ni moverlos, tendrías que copiarlos.
Y así podría seguir infinítamente...
No puedes esperar que solo con "dejar" la carpeta que se llama "Windows" y mover todas las demás carpetas a otra partición te vaya a funcionar el SO, un sistema operativo no funciona de esa manera.
Imagínate que pudieras hacer lo que comentas, dime entonces que pasaría si tienes la carpeta "Windows" almacenada en el disco "C", y todas las demás carpetas que no consideras importantes almacenadas en el disco "D", y luego desconectas el disco D por cualquier motivo? > pantallazo azul al instante xD.
PD: -1 por ser de los que confian en "lo mínimo recomendado" por Microsoft '¬¬
Un saludo!
|
|
|
9133
|
Programación / .NET (C#, VB.NET, ASP) / Re: El Santo Grial de los programadores, como hacer para que se venza al Mes ?
|
en: 30 Abril 2013, 16:43 pm
|
No soy el creador del código, pero te responderé según lo que estuve testeando. Acaso usas la fecha del pc donde corre el programa como referencia ? Si y No, se toma la fecha como referencia para el primer uso, y cuando la fecha cambia (ya séa hacia atrás o hacia delante), cuenta como un día de uso. Es decir, si tenemos un trial de 7 días y Pasan 5 días, quedan 2 días de uso, Si el usuario cambia la fecha a -5 días porque se cree muy listo, ¿al volver a iniciar la aplicación que sucede?, Que se ha restado 1 día de uso, en lugar de 2 días queda 1 día de uso, porque al cambiar la fecha hacia atrás, el programa ha detectado el cambio de fecha y lo ha contado como un día más de uso. ¿Como puede eludir esta protección un usuario?, fácil, no cambiando la fecha en el sistema, mantener siempre la misma fecha, pero no creo que exista nadie que primero se de cuenta y sepa que para evadir la protección hay que hacer eso, y segundo alguien que séa tán retorcido como para perder 1 minuto cada día para vivir siempre en la misma fecha de su puñetero PC xD. No sé que tipo de aplicación haces, pero si no está relacionada con la web entonces no te parece demasiado excesivo querer OBLIGAR a disponer de una conexión de internet para utilizar la aplicación? Un saludo!
|
|
|
9135
|
Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets)
|
en: 30 Abril 2013, 13:26 pm
|
Cambia el theme actual de Windows Os aconsejo cambiar el theme de esta manera en lugar de usar la función SetWindowTheme porque dicha función no cambia el theme corréctamente (no cambia los colores personalizados). #Region " Set Aero Theme " ' [ Set Aero Theme Function ] ' ' // By Elektro H@cker ' ' Instructions : ' Add a reference for "System.ServiceProcess" ' ' Set_Aero_Theme("C:\Windows\Resources\Themes\aero\aero.msstyles") ' Set_Aero_Theme("C:\Windows\Resources\Themes\Concave 7\Concave 7.msstyles") ' Set_Aero_Theme("C:\Windows\Resources\Themes\Aero\Luna.msstyles", "Metallic", "NormalSize") Private Function Set_Aero_Theme(ByVal ThemeFile As String, _ Optional ByVal ColorName As String = "NormalColor", _ Optional ByVal SizeName As String = "NormalSize" _ ) As Boolean Try Using ThemeService As New ServiceProcess.ServiceController("Themes") ThemeService.Stop() ThemeService.WaitForStatus(1) ' Wait for Stopped My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "LoadedBefore", "0", Microsoft.Win32.RegistryValueKind.String) My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", ThemeFile, Microsoft.Win32.RegistryValueKind.String) My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "ColorName", ColorName, Microsoft.Win32.RegistryValueKind.String) My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "SizeName", SizeName, Microsoft.Win32.RegistryValueKind.String) ThemeService.Start() ThemeService.WaitForStatus(4) ' Wait for Running End Using Catch ex As Exception 'MsgBox(ex.message) Return False End Try Return True End Function #End Region
Devuelve información del theme actual PD: Yo solo he creado la función. #Region " Get Current Aero Theme " ' [ Get Current Aero Theme Function ] ' ' // By Elektro H@cker ' ' Examples: ' MsgBox(Get_Current_Aero_Theme(Theme_Info.Name)) ' MsgBox(Get_Current_Aero_Theme(Theme_Info.FullPath)) Public Structure ThemeInfo Private Declare Unicode Function GetCurrentThemeName _ Lib "uxtheme.dll" _ ( _ ByVal pszThemeFileName As String, _ ByVal dwMaxNameChars As Int32, _ ByVal pszColorBuff As String, _ ByVal cchMaxColorChars As Int32, _ ByVal pszSizeBuff As String, _ ByVal cchMaxSizeChars As Int32 _ ) As Int32 Private Const S_OK As Int32 = &H0 Private m_FileName As String Private m_ColorSchemeName As String Private m_SizeName As String Public Property FileName() As String Get Return m_FileName End Get Set(ByVal Value As String) m_FileName = Value End Set End Property Public Property ColorSchemeName() As String Get Return m_ColorSchemeName End Get Set(ByVal Value As String) m_ColorSchemeName = Value End Set End Property Public Property SizeName() As String Get Return m_SizeName End Get Set(ByVal Value As String) m_SizeName = Value End Set End Property Public Overrides Function ToString() As String Return _ "FileName={" & Me.FileName & _ "} ColorSchemeName={" & Me.ColorSchemeName & _ "} SizeName={" & Me.SizeName & "}" End Function Public Shared ReadOnly Property CurrentTheme() As ThemeInfo Get Dim ti As New ThemeInfo() Const BufferLength As Int32 = 256 ti.FileName = Strings.Space(BufferLength) ti.ColorSchemeName = ti.FileName ti.SizeName = ti.FileName If _ GetCurrentThemeName( _ ti.FileName, _ BufferLength, _ ti.ColorSchemeName, _ BufferLength, _ ti.SizeName, _ BufferLength _ ) = S_OK _ Then ti.FileName = NullTrim(ti.FileName) ti.ColorSchemeName = NullTrim(ti.ColorSchemeName) ti.SizeName = NullTrim(ti.SizeName) Return ti Else Const Message As String = _ "An error occured when attempting to get theme info." Throw New Exception(Message) End If End Get End Property Private Shared Function NullTrim(ByVal Text As String) As String Return _ Strings.Left( _ Text, _ Strings.InStr(Text, ControlChars.NullChar) - 1 _ ) End Function End Structure Public Enum Theme_Info Name FileName FullPath ColorScheme Size End Enum Private Function Get_Current_Aero_Theme(ByVal Info As Theme_Info) As String Select Case Info Case Theme_Info.Name : Return ThemeInfo.CurrentTheme.FileName.Split("\").Last.Split(".").First Case Theme_Info.FileName : Return ThemeInfo.CurrentTheme.FileName.Split("\").Last Case Theme_Info.FullPath : Return ThemeInfo.CurrentTheme.FileName Case Theme_Info.ColorScheme : Return ThemeInfo.CurrentTheme.ColorSchemeName Case Theme_Info.Size : Return ThemeInfo.CurrentTheme.SizeName Case Else : Return Nothing End Select End Function #End Region
Escribe texto a la CMD desde un proyecto Windowsforms Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean Declare Function FreeConsole Lib "kernel32.dll" () As Boolean AttachConsole(-1) ' Attach the console System.Console.Writeline("I am writing from a WinForm to the console!") FreeConsole() ' Desattach the console
Adjunta una nueva instancia de la CMD a la aplicación. Public Declare Function AllocConsole Lib "kernel32.dll" () As Boolean AllocConsole() Console.WriteLine("this is my console!") : Threading.Thread.Sleep(5000)
Detecta si la aplicación se ejecutó desde la consola Un ejemplo de uso? Pues por ejemplo el que yo le doy, si el usuario ejecuta la aplicación desde la consola entonces muestro una ayuda sobre la sintaxis y etc en la consola, de lo contrario obviamente no muestro nada. #Region " App Is Launched From CMD? " ' [ App Is Launched From CMD? Function ] ' ' // By Elektro H@cker ' ' Examples: ' MsgBox(App_Is_Launched_From_CMD) ' If App_Is_Launched_From_CMD() Then Console.WriteLine("Help for this application: ...") Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean Declare Function FreeConsole Lib "kernel32.dll" () As Boolean Private Function App_Is_Launched_From_CMD() As Boolean If AttachConsole(-1) Then FreeConsole() Return True Else Return False End If End Function #End Region
Parte un archivo de texto en trozos especificando el tamaño. PD: El code no es de mi propiedad pero lo he sacado de un código de C# y lo he retocado casi por completo para hacerlo más funcional, así que me doy los créditos. #Region " Split File " ' [ Split File Function ] ' ' // By Elektro H@cker ' ' Examples : ' MsgBox(Split_File("C:\Test.txt", 10000, , True)) ' MsgBox(Split_File("C:\Test.txt", 10000, "Splitted")) Public Function Split_File (ByVal File As String, _ ByVal ChunkSize As Long, _ Optional ByVal OutputName As String = Nothing, _ Optional ByVal Preserve_FileExtension As Boolean = True _ ) As Boolean Dim Index As Long Dim OutputFile As String Dim BaseName As String Dim StartPosition As Long Dim Buffer As Byte() = New Byte() {} Dim InputFileStram As System.IO.FileStream Dim OutputFileStram As System.IO.FileStream Dim BinaryWriter As IO.BinaryWriter Dim BinaryReader As IO.BinaryReader Dim Fragments As Long Dim RemainingBytes As Long Dim Progress As Double Dim Zeroes As String = "" Try Dim FileInfo As New IO. FileInfo(File) Dim Filename As String = FileInfo.FullName Dim FileExtension As String = FileInfo.Extension Dim outputpath As String = FileInfo.DirectoryName Dim FileSize As Long = FileInfo.Length If OutputName IsNot Nothing Then : BaseName = OutputName Else : BaseName = FileInfo.Name.Replace(FileInfo.Extension, "") : End If If Not IO. File. Exists(Filename ) Then MsgBox("File " & Filename & " doesn't exist") Return False End If If FileSize <= ChunkSize Then MsgBox(Filename & " size(" & FileSize & ") is less than the ChunkSize(" & ChunkSize & ")") Return False End If InputFileStram = New IO.FileStream(Filename, IO.FileMode.Open) BinaryReader = New IO.BinaryReader(InputFileStram) Fragments = Math.Floor(FileSize / ChunkSize) For n As Integer = 1 To Fragments.ToString.Length : Zeroes += "0" : Next Progress = 100 / Fragments RemainingBytes = FileSize - (Fragments * ChunkSize) If outputpath = "" Then outputpath = IO.Directory.GetParent(Filename).ToString If Not IO.Directory.Exists(outputpath) Then IO.Directory.CreateDirectory(outputpath) BinaryReader.BaseStream.Seek(0, IO.SeekOrigin.Begin) For Index = 1 To Fragments If Preserve_FileExtension Then : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes) & FileExtension Else : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes) End If ReDim Buffer(ChunkSize - 1) BinaryReader.Read(Buffer, 0, ChunkSize) StartPosition = BinaryReader.BaseStream.Seek(0, IO.SeekOrigin.Current) If IO. File. Exists(OutputFile ) Then IO. File. Delete(OutputFile ) OutputFileStram = New System.IO.FileStream(OutputFile, IO.FileMode.Create) BinaryWriter = New IO.BinaryWriter(OutputFileStram) BinaryWriter.Write(Buffer) OutputFileStram.Flush() BinaryWriter.Close() OutputFileStram.Close() Next If RemainingBytes > 0 Then If Preserve_FileExtension Then : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes) & FileExtension Else : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes) End If ReDim Buffer(RemainingBytes - 1) BinaryReader.Read(Buffer, 0, RemainingBytes) If IO. File. Exists(OutputFile ) Then IO. File. Delete(OutputFile ) OutputFileStram = New System.IO.FileStream(OutputFile, IO.FileMode.Create) BinaryWriter = New IO.BinaryWriter(OutputFileStram) BinaryWriter.Write(Buffer) OutputFileStram.Flush() BinaryWriter.Close() OutputFileStram.Close() End If InputFileStram.Close() BinaryReader.Close() Return True Catch ex As Exception MsgBox(ex.Message) Return False Finally BinaryWriter = Nothing OutputFileStram = Nothing BinaryReader = Nothing InputFileStram = Nothing End Try End Function #End Region
Parte un archivo de texto en trozos especificando el número de líneas por archivo. #Region " Split TextFile By Number Of Lines " ' [ Split TextFile By Number Of Lines Function ] ' ' // By Elektro H@cker ' ' Examples : ' Split_TextFile_By_Number_Of_Lines("C:\Test.txt", 10000) ' MsgBox(Split_TextFile_By_Number_Of_Lines("C:\Test.txt", 10)) Private Function Split_TextFile_By_Number_Of_Lines(ByVal TextFile As String, ByVal NumberOfLines As Long) As Boolean Try Dim FileInfo As New IO.FileInfo(TextFile) If NumberOfLines > IO. File. ReadAllLines(TextFile ). Length Then ' MsgBox("Number of lines is greater than total file lines") Return False End If Using sr As New System.IO.StreamReader(TextFile) Dim fileNumber As Integer = 0 While Not sr.EndOfStream Dim count As Integer = 0 Using sw As New System.IO.StreamWriter(FileInfo.DirectoryName & "\" & FileInfo.Name.Replace(FileInfo.Extension, " " & System.Threading.Interlocked.Increment(fileNumber) & FileInfo.Extension)) sw.AutoFlush = True While Not sr.EndOfStream AndAlso Not System.Threading.Interlocked.Increment(count) > NumberOfLines Application.DoEvents() sw.WriteLine(sr.ReadLine()) End While End Using End While End Using Return True Catch ex As Exception Throw New Exception(ex.Message) End Try End Function #End Region
|
|
|
9136
|
Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets)
|
en: 30 Abril 2013, 13:19 pm
|
If Debug conditional #Else #End If
If Debugger IsAttached conditional Ejemplo de una condicional de ejecución en Debug If Debugger.IsAttached Then Else End If
String Format Ejemplo de un String Format MsgBox(String.Format("{0}+{1} = {2}", "Uno", "Dos", "Tres"))
Get NT Version Devuelve la versión NT de Windows PD: He omitido Windows 3.51 para no complicar el código, pero a quien le importa eso, ¿No? #Region " Get NT Version " ' [ Get NT Version Function ] ' ' // By Elektro H@cker ' ' Examples : ' MsgBox(Get_NT_Version()) ' If Get_NT_Version() < 6.0 Then MsgBox("This application only works with an Aero compatible windows version") Private Function Get_NT_Version() As Double Dim NT As Double = CDbl(Val(System.Environment.OSVersion.Version.ToString.Substring(0, 3))) ' INFO: ' ----- ' 3.1 = Windows NT 3.1 ' 3.5 = Windows NT 3.5 ' 4.0 = Windows NT 4.0 ' 5.0 = Windows 2000 ' 5.1 = Windows XP / Windows Fundamentals for Legacy PCs ' 5.2 = Windows XP 64 Bit / Windows server 2003 / Windows server 2003 R2 / Windows home Server ' 6.0 = Windows VISTA / Windows server 2008 ' 6.1 = Windows 7 / Windows server 2008 R2 ' 6.2 = Windows 8 / Windows 8 Phone / Windows Server 2012 Return NT End Function
#End Region
Extract Icon Devuelve el icono de un archivo #Region " Extract Icon " ' [ Extract Icon Function ] ' ' // By Elektro H@cker ' ' Me.Icon = Extract_Icon("c:\windows\explorer.exe") ' Dim MyIcon as System.Drawing.Icon = Extract_Icon("c:\Test.txt") Private Function Extract_Icon (ByVal File As String) As System. Drawing. Icon Try : Return System. Drawing. Icon. ExtractAssociatedIcon(File) Catch ex As Exception 'MsgBox(ex.message) Return Nothing End Try Else : Return Nothing End If End Function #End Region
[OSVersionInfo] - Examples Ejemplos de uso de OSVersionInfo Se necesita esta class (o la dll): http://www.codeproject.com/Articles/73000/Getting-Operating-System-Version-Info-Even-for-Win MsgBox(OSVersionInfo.Name) MsgBox(OSVersionInfo.Edition) MsgBox(OSVersionInfo.ServicePack) MsgBox(OSVersionInfo.VersionString) MsgBox(OSVersionInfo.BuildVersion) MsgBox(OSVersionInfo.OSBits.ToString) MsgBox(OSVersionInfo.ProcessorBits.ToString) MsgBox(OSVersionInfo.ProgramBits.ToString)
|
|
|
9137
|
Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets)
|
en: 30 Abril 2013, 13:15 pm
|
[ListView] Restrict column resizing Restringe cambiar de tamaño una columna. ' [ListView] Restrict column resizing Private Sub ListView1_ColumnWidthChanging(sender As Object, e As ColumnWidthChangingEventArgs) Handles ListView1.ColumnWidthChanging e.Cancel = True e.NewWidth = sender.Columns(e.ColumnIndex).Width End Sub
Get Non-Client Area Width Devuelve el tamaño del borde del área NO cliente de la aplicación. #Region " Get Non-Client Area Width " ' [ Get Non-Client Area Width Function ] ' ' // By Elektro H@cker ' ' Examples : ' MsgBox(Get_NonClientArea_Width(Form1)) ' Me.Location = New Point((Form1.Location.X + (Form1.Width + Get_NonClientArea_Width(Form1))), Form1.Location.Y) Private Function Get_NonClientArea_Width(ByVal Form As Form) As Int32 Return (Form.Width - Form.ClientSize.Width) End Function #End Region
Extend Non Client Area Extiende el área NO cliente al área cliente de la aplicación #Region " Extend Non Client Area " ' [ Extend Non Client Area Function ] ' ' // By Elektro H@cker ' ' Examples : ' Extend_Non_Client_Area(Me.Handle, 50, 50, -0, 20) ' MsgBox(Extend_Non_Client_Area(12345, -1, -1, -1, -1)) <System.Runtime.InteropServices.DllImport("dwmapi.dll")> _ Private Shared Function DwmExtendFrameIntoClientArea(ByVal handle As IntPtr, ByRef Margins As MARGINS) As Integer End Function <System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)> _ Public Structure MARGINS Public Left As Integer Public Right As Integer Public Up As Integer Public Down As Integer End Structure Private Function Extend_Non_Client_Area(ByVal Window_Handle As IntPtr, _ ByVal Left As Int32, _ ByVal Right As Int32, _ ByVal Up As Int32, _ ByVal Down As Int32) As Boolean Try Dim Margins As New MARGINS() Margins.Left = Left Margins.Right = Right Margins.Up = Up Margins.Down = Down DwmExtendFrameIntoClientArea(Window_Handle, Margins) Return True Catch ex As Exception 'Return false Throw New Exception(ex.Message) End Try End Function #End Region
|
|
|
9140
|
Programación / .NET (C#, VB.NET, ASP) / Re: Detener servicios de windows
|
en: 30 Abril 2013, 13:06 pm
|
Bueno para quien le interese,es que la libreria System.ServiceProcess no funciona en 64 bits,lo he probado en 32 bits y funciona perfectamente. No se si es porque es windows 8 o por que el sistema es 64 bits.
Hola, solo quiero decirte que lo de los 64bits es una tontería, yo uso Windows 7 de 64 bits y como ves te mostré un código funcional. Lo de que no te funcione porque séa Windows 8 también parece otra tontería, si no fuesen compatible las classes del FW en Windows 8 sería para darle una tremenda hostia a Microsoft, pero eso ya no te lo puedo confirmar. un saludo! EDITO: Quizás si pruebas mi aplicación te pueda sacar de dudas si la "System.Serviceprocess" funciona en Win8 de 64 bits o no: http://foro.elhacker.net/net/aporte_aeroswitcher-t389187.0.html;msg1849223#msg1849223
|
|
|
|
|
|
|