elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


  Mostrar Mensajes
Páginas: 1 ... 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [23] 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ... 41
221  Programación / .NET (C#, VB.NET, ASP) / Re: Guardar Imagen en base de datos. (c#) en: 13 Junio 2010, 23:50 pm
Cuando necesite guardar imagenes en una BD los ejemplos que encontre primero guardaban la imagen en disco. Por eso yo lo hice de este modo:

Código
  1. System.IO.Stream derecho = new System.IO.MemoryStream();
  2. this.picDerecha.Image.Save(derecho, System.Drawing.Imaging.ImageFormat.Jpeg);
  3. byte[] imgDerecha = new byte[derecho.Length];
  4. derecho.Position = 0;
  5. derecho.Read(imgDerecha, 0, System.Convert.ToInt32(derecho.Length));
  6. derecho.Close();

Código
  1. myRow["IDerecha"] = imgDerecha;

gracias voy a probar, pero así leyendo por encima he visto esto:

Código:
img.Save(fs, System.Drawing.Imaging.ImageFormat.Png);

Si la imágen que yo he escogido anteriormente para mi picturebox no es png que hago??.

Solo cambias:

Código
  1. System.Drawing.Imaging.ImageFormat.Jpeg

por la extension que necesites.
222  Programación / .NET (C#, VB.NET, ASP) / Re: como crear un instalador en vb 2005 en: 10 Junio 2010, 17:10 pm
Fijate aqui como se puede hacer como archivo adjunto:

http://geeks.ms/blogs/sergiotarrillo/archive/2006/11/16/cadenas-de-conexion-desde-net-para-sql-server-2005.aspx

asi solo registras tu BD en el servidor y la conexion es la misma.

O si prefieres hacerlo como hasta ahora, puedes usar este ejemplo:

http://www.elguille.info/NET/adonet/Crear_una_base_de_datos_de_SQL_Server_mediante_codigo_de_Visual_Basic.htm

Lo modificas y en tiempo de ejecucion puedes obtener la cadena de conexion para tu BD.
223  Programación / .NET (C#, VB.NET, ASP) / Re: c# creacion de bots para juegos? en: 10 Junio 2010, 17:06 pm
Basicamente se hace una captura de la pantalla mediante codigo y se obtiene los pixeles (getpixel) de determinadas coordenadas, luego estas se comparan con una o varias imagenes base (almacenadas en una base de datos) que sirven para obtener por ejemplo el nombre del usuario o la posicion de algun jugador. Al principio es mejor hacerlo con pictures box para ver como funciona, luego se pueden omitir e incluso la captura de la pantalla.

Es el metodo basico, porque se puede hacer solamente con vectores de numeros (omitiendo las imagenes base).
224  Programación / .NET (C#, VB.NET, ASP) / Re: como crear un instalador en vb 2005 en: 10 Junio 2010, 05:40 am
Buen dia

Recien acabo de terminar un programa sencillo en vb.net.
- y quiero crearle un instalador a mi programa, pero no se como hacerlo y creo que habran algunos errores con respecto al codigo de mi programa, me explico:

- El programa lo hice en Visual Basic.net 2005.
- La base de datos esta en SQL Server 2005.

En mi programa (vb.net) use un modulo el cual contiene la conexion para poder usar la base de datos (sql server): (use public para poder usar la conexion en todo mi programa)


Código:
Imports System.Data
Imports System.Data.SqlClient

Module Module1
    Public conectar As New SqlConnection("Data Source=Pc01\sqlexpress;Initial Catalog=Proyecto;Integrated Security=True")

End Module

Por logica esta conexion si funciona en mi compu y el programa me anda bien, pero si quiero usar mi proyecto en otra compu me dara error de conexion pues la conexion no es la misma y tendria que modificarla


- Bueno, lo que deseo hacer es que el programa pueda instalarse en cualquier computadora, y que funcione perfectamente, pero no tengo ni idea de como hacer el instalador, y que pasaria con el codigo del modulo para conectarme con la base de datos?

- ah se me olvidaba, tengo que pasar mi programa a un exe, antes de crearle el instalador?


Cualquier duda pueden preguntar, de antemano gracias


salu2


Puedes usar una cadena de conexion con una BD adjuntada, asi en el instalador puedes añadir el archivo *.mdf y simplemente adjuntar dicho archivo al servidor SQLServer y no tener que crearla en dicho servidor, o podrias comprobar si existe y crearla en el mismo.

Respecto al instalador si solo estas practicando y lo haces mediante un proyecto de instalación en VS y mas adelante quieres utilizar el mismo método para alguna aplicación comercial dependiendo de su alcance ten en cuenta el tema de la licencia.

El uso de SQL Server depende de las caracteristicas de tu programa y el tipo de uso que tendrá, porque puedes optar por Acces y evitar la instalación de MSSQL si no es necesaria.

Hay mas cosas que considerar, pero creo que esto es suficiente.
225  Programación / .NET (C#, VB.NET, ASP) / Re: c# creacion de bots para juegos? en: 10 Junio 2010, 05:10 am
Hola, hace poco senti una curiosidad sobre este tema, me gustaria saber el funcionamiento de un bot en un juego, es decir como desde mi aplicacion mandar ordenes que el juego entienda y las ejecute, me gustaria saber por donde empezar a buscar informacion sobre este tema, como interpretar las ordenes del juego para adaptarlas a mi programa y como conectarlos entre si, si alguien me pudiera orientar estaria agredcido!

Creo que esto puede orientarte un poco:

http://nidodecuervos.comentalo.net/bot-simple-php-world-of-warcraft-linux.htm

Bueno, no conozco el juego que mencionas, pero no veo complicado el enviarle ordenes si esta hecho en ASx (Flash) y supongo que tiene trucos o combinaciones de teclas para atajos u otros que se pueden aprovechar, pero depende del nivel de proteccion que tenga dicho juego para algun bot, respecto a que el bot pueda reconocer areas o personajes del juego, simplemente con una captura de la pantalla o indicando las coordenadas y un procesado de imagenes (metodo cutre pero sirve para empezar) que en c#.net te lo da practicamente hecho solo implementar un algoritmo adecuado de comparacion de imagenes + una pequeña BD para garantizar el reconocimiento de dichas areas o personajes.
Se me ocurre que se podria averiguar como envia y recibe la informacion del servidor para implementar la IA de modo que funcione de forma mas precisa.
Bueno de seguro hay mejores modos de hacerlo, pero tu eres el que debe ir investigando al respecto.
226  Programación / .NET (C#, VB.NET, ASP) / Re: Manejar webcam en VS 2010 en: 8 Junio 2010, 05:21 am
Saludos a toda esta maravillosa comunidad. Estoy necesitando integrar la imagen de una webcam en un form, dentro de un picturebox. Estuve buscando mucho por la red y ninguno de los ejemplos que encontre funciono. Estoy trabajando con VS 2010, ojala puedan darme una manito.
Saludos, y muchas gracias por su ayuda y por su tiempo

Lo mas sencillo es utilizar las API's de Windows, hay ejemplos de clases ya hechas en la red, hasta en el mismo foro:

http://foro.elhacker.net/vbnet/clase_para_capturar_fotos_con_la_webcam_c-t172433.0.html

para utilizar esa clase  debes tener en tu form un picture box y un combo box.

Pero es mucho mejor utilizar DirectShow.NET

http://www.codeproject.com/KB/directx/directshownet.aspx?display=Print

En ese enlace esta mas detallado.
227  Programación / Desarrollo Web / Re: Acceder a la camara web en: 6 Junio 2010, 19:09 pm
Ya mencionaste a Flash y de hecho AS --> ya tienes la respuesta a la 1era busqueda en google... :huh:

http://www.google.com.bo/#hl=es&&sa=X&ei=J9MLTNK4HoO88gbVuZWNBw&ved=0CBMQBSgA&q=capturar+webcam+as3&spell=1&fp=504413e5e9bfcdb8

por lo menos respecto a flash, en el 1er enlace de la busqueda te muestra el source y el ejemplo
228  Programación / Programación General / Re: Consulta J# en: 5 Junio 2010, 05:46 am
Hola, queria saber si es posible controlar el volumen de windows con J#.net

Si se puede, este ejemplo en c#.net disminuye el volumen general de windows puedes pasarlo a J#.NET y modificarlo a tu gusto, hay muchos mas en la red.

Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Media;
  10. using System.Runtime.InteropServices;
  11.  
  12. namespace WindowsFormsApplication1
  13. {
  14.    public partial class Form1 : Form
  15.    {
  16.        public const int MMSYSERR_NOERROR = 0;
  17.        public const int MAXPNAMELEN = 32;
  18.        public const int MIXER_LONG_NAME_CHARS = 64;
  19.        public const int MIXER_SHORT_NAME_CHARS = 16;
  20.        public const int MIXER_GETLINEINFOF_COMPONENTTYPE = 0x3;
  21.        public const int MIXER_GETCONTROLDETAILSF_VALUE = 0x0;
  22.        public const int MIXER_GETLINECONTROLSF_ONEBYTYPE = 0x2;
  23.        public const int MIXER_SETCONTROLDETAILSF_VALUE = 0x0;
  24.        public const int MIXERLINE_COMPONENTTYPE_DST_FIRST = 0x0;
  25.        public const int MIXERLINE_COMPONENTTYPE_SRC_FIRST = 0x1000;
  26.        public const int MIXERLINE_COMPONENTTYPE_DST_SPEAKERS =
  27.        (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4);
  28.        public const int MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE =
  29.        (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3);
  30.        public const int MIXERLINE_COMPONENTTYPE_SRC_LINE =
  31.        (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2);
  32.        public const int MIXERCONTROL_CT_CLASS_FADER = 0x50000000;
  33.        public const int MIXERCONTROL_CT_UNITS_UNSIGNED = 0x30000;
  34.        public const int MIXERCONTROL_CONTROLTYPE_FADER =
  35.        (MIXERCONTROL_CT_CLASS_FADER | MIXERCONTROL_CT_UNITS_UNSIGNED);
  36.        public const int MIXERCONTROL_CONTROLTYPE_VOLUME =
  37.        (MIXERCONTROL_CONTROLTYPE_FADER + 1);
  38.  
  39.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  40.        private static extern int mixerClose(int hmx);
  41.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  42.        private static extern int mixerGetControlDetailsA(int hmxobj, ref
  43. MIXERCONTROLDETAILS pmxcd, int fdwDetails);
  44.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  45.        private static extern int mixerGetDevCapsA(int uMxId, MIXERCAPS
  46.        pmxcaps, int cbmxcaps);
  47.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  48.        private static extern int mixerGetID(int hmxobj, int pumxID, int
  49.        fdwId);
  50.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  51.        private static extern int mixerGetLineControlsA(int hmxobj, ref
  52. MIXERLINECONTROLS pmxlc, int fdwControls);
  53.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  54.        private static extern int mixerGetLineInfoA(int hmxobj, ref
  55. MIXERLINE pmxl, int fdwInfo);
  56.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  57.        private static extern int mixerGetNumDevs();
  58.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  59.        private static extern int mixerMessage(int hmx, int uMsg, int
  60.        dwParam1, int dwParam2);
  61.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  62.        private static extern int mixerOpen(out int phmx, int uMxId,
  63.        int dwCallback, int dwInstance, int fdwOpen);
  64.        [DllImport("winmm.dll", CharSet = CharSet.Ansi)]
  65.        private static extern int mixerSetControlDetails(int hmxobj, ref
  66. MIXERCONTROLDETAILS pmxcd, int fdwDetails);
  67.  
  68.        public struct MIXERCAPS
  69.        {
  70.            public int wMid;
  71.            public int wPid;
  72.            public int vDriverVersion;
  73.            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAXPNAMELEN)]
  74.            public string szPname;
  75.            public int fdwSupport;
  76.            public int cDestinations;
  77.        }
  78.  
  79.        public struct MIXERCONTROL
  80.        {
  81.            public int cbStruct;
  82.            public int dwControlID;
  83.            public int dwControlType;
  84.            public int fdwControl;
  85.            public int cMultipleItems;
  86.            [MarshalAs(UnmanagedType.ByValTStr,
  87.            SizeConst = MIXER_SHORT_NAME_CHARS)]
  88.            public string szShortName;
  89.            [MarshalAs(UnmanagedType.ByValTStr,
  90.            SizeConst = MIXER_LONG_NAME_CHARS)]
  91.            public string szName;
  92.            public int lMinimum;
  93.            public int lMaximum;
  94.            [MarshalAs(UnmanagedType.U4, SizeConst = 10)]
  95.            public int reserved;
  96.        }
  97.  
  98.        public struct MIXERCONTROLDETAILS
  99.        {
  100.            public int cbStruct;
  101.            public int dwControlID;
  102.            public int cChannels;
  103.            public int item;
  104.            public int cbDetails;
  105.            public IntPtr paDetails;
  106.        }
  107.  
  108.        public struct MIXERCONTROLDETAILS_UNSIGNED
  109.        {
  110.            public int dwValue;
  111.        }
  112.  
  113.        public struct MIXERLINE
  114.        {
  115.            public int cbStruct;
  116.            public int dwDestination;
  117.            public int dwSource;
  118.            public int dwLineID;
  119.            public int fdwLine;
  120.            public int dwUser;
  121.            public int dwComponentType;
  122.            public int cChannels;
  123.            public int cConnections;
  124.            public int cControls;
  125.            [MarshalAs(UnmanagedType.ByValTStr,
  126.            SizeConst = MIXER_SHORT_NAME_CHARS)]
  127.            public string szShortName;
  128.            [MarshalAs(UnmanagedType.ByValTStr,
  129.            SizeConst = MIXER_LONG_NAME_CHARS)]
  130.            public string szName;
  131.            public int dwType;
  132.            public int dwDeviceID;
  133.            public int wMid;
  134.            public int wPid;
  135.            public int vDriverVersion;
  136.            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAXPNAMELEN)]
  137.            public string szPname;
  138.        }
  139.  
  140.        public struct MIXERLINECONTROLS
  141.        {
  142.            public int cbStruct;
  143.            public int dwLineID;
  144.  
  145.            public int dwControl;
  146.            public int cControls;
  147.            public int cbmxctrl;
  148.            public IntPtr pamxctrl;
  149.        }
  150.  
  151.        private bool GetVolumeControl(int hmixer, int componentType,
  152.        int ctrlType, out MIXERCONTROL mxc, out int vCurrentVol)
  153.            {
  154.            // This function attempts to obtain a mixer control.
  155.            // Returns True if successful.
  156.            MIXERLINECONTROLS mxlc = new MIXERLINECONTROLS();
  157.            MIXERLINE mxl = new MIXERLINE();
  158.            MIXERCONTROLDETAILS pmxcd = new MIXERCONTROLDETAILS();
  159.            MIXERCONTROLDETAILS_UNSIGNED du = new
  160.                MIXERCONTROLDETAILS_UNSIGNED();
  161.            mxc = new MIXERCONTROL();
  162.            int rc;
  163.            bool retValue;
  164.            vCurrentVol = -1;
  165.            mxl.cbStruct = Marshal.SizeOf(mxl);
  166.            mxl.dwComponentType = componentType;
  167.            rc = mixerGetLineInfoA(hmixer,ref mxl,
  168.                MIXER_GETLINEINFOF_COMPONENTTYPE );
  169.            if(MMSYSERR_NOERROR == rc)
  170.                {
  171.                int sizeofMIXERCONTROL = 152;
  172.                int ctrl = Marshal.SizeOf(typeof(MIXERCONTROL));
  173.                mxlc.pamxctrl = Marshal.AllocCoTaskMem(sizeofMIXERCONTROL);
  174.                mxlc.cbStruct = Marshal.SizeOf(mxlc);
  175.                mxlc.dwLineID = mxl.dwLineID;
  176.                mxlc.dwControl = ctrlType;
  177.                mxlc.cControls = 1;
  178.                mxlc.cbmxctrl = sizeofMIXERCONTROL;
  179.                // Allocate a buffer for the control
  180.                mxc.cbStruct = sizeofMIXERCONTROL;
  181.                // Get the control
  182.                rc = mixerGetLineControlsA(hmixer,ref mxlc,
  183.                    MIXER_GETLINECONTROLSF_ONEBYTYPE);
  184.                if(MMSYSERR_NOERROR == rc)
  185.                    {
  186.                    retValue = true;
  187.                    // Copy the control into the destination structure
  188.                    mxc = (MIXERCONTROL)Marshal.PtrToStructure(
  189.                        mxlc.pamxctrl,typeof(MIXERCONTROL));
  190.                    }
  191.                    else
  192.                    {
  193.                    retValue = false;
  194.                    }
  195.                int sizeofMIXERCONTROLDETAILS =
  196.                    Marshal.SizeOf(typeof(MIXERCONTROLDETAILS));
  197.                int sizeofMIXERCONTROLDETAILS_UNSIGNED =
  198.                    Marshal.SizeOf(typeof(MIXERCONTROLDETAILS_UNSIGNED ));
  199.                pmxcd.cbStruct = sizeofMIXERCONTROLDETAILS;
  200.                pmxcd.dwControlID = mxc.dwControlID;
  201.                pmxcd.paDetails = Marshal.AllocCoTaskMem(sizeofMIXERCONTROLDETAILS_UNSIGNED) ;
  202.                pmxcd.cChannels = 1;
  203.                pmxcd.item = 0;
  204.                pmxcd.cbDetails = sizeofMIXERCONTROLDETAILS_UNSIGNED;
  205.                rc = mixerGetControlDetailsA(hmixer,ref pmxcd,
  206.                    MIXER_GETCONTROLDETAILSF_VALUE);
  207.                du = (MIXERCONTROLDETAILS_UNSIGNED)Marshal.PtrToStructure(
  208.                    pmxcd.paDetails, typeof(MIXERCONTROLDETAILS_UNSIGNED));
  209.                vCurrentVol = du.dwValue;
  210.                return retValue;
  211.                }
  212.            retValue = false;
  213.            return retValue;
  214.            }
  215.        private static bool SetVolumeControl(int hmixer, MIXERCONTROL mxc, int volume)
  216.            {
  217.            // This function sets the value for a volume control.
  218.            // Returns True if successful
  219.            bool retValue;
  220.            int rc;
  221.            MIXERCONTROLDETAILS mxcd = new MIXERCONTROLDETAILS();
  222.            MIXERCONTROLDETAILS_UNSIGNED vol = new
  223.            MIXERCONTROLDETAILS_UNSIGNED();
  224.            mxcd.item = 0;
  225.            mxcd.dwControlID = mxc.dwControlID;
  226.            mxcd.cbStruct = Marshal.SizeOf(mxcd);
  227.            mxcd.cbDetails = Marshal.SizeOf(vol);
  228.  
  229.            // Allocate a buffer for the control value buffer
  230.            mxcd.cChannels = 1;
  231.            vol.dwValue = volume;
  232.  
  233.            // Copy the data into the control value buffer
  234.            mxcd.paDetails = Marshal.AllocCoTaskMem(Marshal.SizeOf(
  235.            typeof(MIXERCONTROLDETAILS_UNSIGNED)));
  236.            Marshal.StructureToPtr(vol, mxcd.paDetails, false);
  237.  
  238.            // Set the control value
  239.            rc = mixerSetControlDetails(hmixer, ref mxcd,
  240.            MIXER_SETCONTROLDETAILSF_VALUE);
  241.  
  242.            if (MMSYSERR_NOERROR == rc)
  243.            {
  244.                retValue = true;
  245.            }
  246.            else
  247.            {
  248.                retValue = false;
  249.            } return retValue;
  250.        }
  251.  
  252.        public int GetVolume()
  253.        {
  254.            int mixer;
  255.            MIXERCONTROL volCtrl = new MIXERCONTROL();
  256.            int currentVol;
  257.            mixerOpen(out mixer, 0, 0, 0, 0);
  258.            int type = MIXERCONTROL_CONTROLTYPE_VOLUME;
  259.            GetVolumeControl(mixer,
  260.            MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, type, out volCtrl, out currentVol);
  261.            mixerClose(mixer);
  262.            return currentVol;
  263.        }
  264.  
  265.        public void SetVolume(int vVolume)
  266.        {
  267.            int mixer;
  268.            MIXERCONTROL volCtrl = new MIXERCONTROL();
  269.            int currentVol;
  270.            mixerOpen(out mixer, 0, 0, 0, 0);
  271.            int type = MIXERCONTROL_CONTROLTYPE_VOLUME;
  272.            GetVolumeControl(mixer,
  273.            MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, type, out volCtrl, out currentVol);
  274.            if (vVolume > volCtrl.lMaximum) vVolume = volCtrl.lMaximum;
  275.            if (vVolume < volCtrl.lMinimum) vVolume = volCtrl.lMinimum;
  276.            SetVolumeControl(mixer, volCtrl, vVolume);
  277.            GetVolumeControl(mixer,
  278.            MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, type, out volCtrl, out currentVol);
  279.            if (vVolume != currentVol)
  280.            {
  281.                throw new Exception("Cannot Set Volume");
  282.            }
  283.            mixerClose(mixer);
  284.  
  285.        }
  286.        public Form1()
  287.        {
  288.            InitializeComponent();
  289.        }
  290.  
  291.        private void Form1_Load(object sender, EventArgs e)
  292.        {
  293.  
  294.        }
  295.  
  296.        private void button1_Click(object sender, EventArgs e)
  297.        {
  298.            MessageBox.Show( this.GetVolume().ToString());
  299.            //set the master volume
  300.             this.SetVolume(1000);
  301.            //Display the new volume
  302.            MessageBox.Show(this.GetVolume().ToString());
  303.        }
  304.    }
  305. }
  306.  
229  Programación / .NET (C#, VB.NET, ASP) / Re: Formulario dentro de otro Formulario???? C# en: 5 Junio 2010, 05:00 am
Prueba con este enlace:

http://geeks.ms/blogs/lfranco/archive/2008/07/01/how-to-c-243-mo-insertar-un-winform-dentro-de-un-control-tabpanel.aspx

en otro caso puedes usar el Control de Usuario que es una buena opcion.
230  Programación / Programación C/C++ / Re: cambiar bit de imagen en: 31 Mayo 2010, 21:35 pm
alguien puede decirme como se cambian los bits en una imagen  para poder guardar otra informacion extra en esa imagen

Supongo que hablas de Esteganografia en *.BMP aqui hay una explicación sencilla al respecto:

http://carlosagreda.blogspot.com/2008/02/esteganografia-en-imagenes.html

Aunque el proyecto esta hecho en VB6, hay muchos ejempos en c++ en la red.
Páginas: 1 ... 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [23] 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ... 41
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines