Mobile开发搜集整理的资料

     Mobile开发也有好几个项目了,期间从互联网上整理很多Mobile开发资料,为了方便更多的人节省搜集时间,现将部分搜集而来Mobile开发资料整理成一个项目,方便自己,也方便同仁们学习查阅!--- 源于 博客园

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Windows.Forms;
using Application.Framework.Win32;
using System.ComponentModel;
using System.Security.Cryptography;
using System.IO;
using Microsoft.Win32;

namespace Application.Framework.GetPDADetail
{
    
public class PDAOperate
    
{
        
#region---获取UUID号码---
        
public static string GetIMSINumber()
        
{
            
string number = Sim.ControlTapi.GetIMSINumber();
            
if (number == null || number.Length == 0)
                
return "0000";

            
return GetMD5(number);
        }

        
#endregion


        
#region---MD5加密---
        
public static string GetMD5(string key)
        
{
            MD5 md5 
= MD5.Create();
            
byte[] byteResult = md5.ComputeHash(Encoding.Default.GetBytes(key));
            StringBuilder md5Result 
= new StringBuilder(32);
            
for (int i = 0; i < byteResult.Length; i++)
            
{
                md5Result.Append(byteResult[i].ToString(
"x2"));
            }

            
return md5Result.ToString();
        }

        
#endregion


        
#region ---设置开机画面---
        
/// <summary>
        
/// 设置开机画面
        
/// </summary>
        
/// <param name="path">图片的路径</param>
        
/// <returns></returns>

        protected void SetStartUpPic(string path)
        
{
            RegistryKey key 
= Registry.LocalMachine.OpenSubKey(@"SOFTWARE/HTC/StartupAnimation"true);
            
if (key == null)
            
{
                MessageBox.Show(
"键值不存在");
            }

            
else
            
{
                
if (File.Exists(path))
                
{
                    key.SetValue(
"GIFFile", path);
                    MessageBox.Show(
"设置开机画面成功");
                }

                
else
                
{
                    MessageBox.Show(
"图片不存在");
                }

            }

        }


        
#endregion


        
#region ---屏蔽Dll弹出(安全性)---
        
/// <summary>
        
/// 屏蔽Dll弹出
        
/// </summary>
        
/// <returns></returns>

        protected void SetSecurity()
        
{
            
try
            
{
                RegistryKey key 
= Registry.LocalMachine.OpenSubKey(@"Security/Policies/Policies"true);
                
if (key == null)
                
{
                    MessageBox.Show(
"键值不存在");
                }

                
else
                
{
                    key.SetValue(
"0000101a"1);
                    MessageBox.Show(
"屏蔽Dll成功!");
                }

            }

            
catch (Exception)
            
{
                MessageBox.Show(
"异常");
            }

        }

        
#endregion


        
#region---获取PDA版本型号,例如E616---
        
public static string GetPDAType()
        
{
            
return System.Net.Dns.GetHostName();
        }

        
#endregion


        
#region ---重新启动PDA---
    
        
enum ExitWindowsAction : uint
        
{
            EWX_LOGOFF 
= 0,
            EWX_SHUTDOWN 
= 1,
            EWX_REBOOT 
= 2,
            EWX_FORCE 
= 4,
            EWX_POWEROFF 
= 8
        }

        
public static void ExitPDA()
        
{
            
uint i = 2;
            
uint b = 0;
            CoreDLL.ExitWindowsEx(i, b);
//2,0系统重起
        }

        
#endregion


        
#region--一定时间内重新启动应用程序---
        
public static void ReRunApplication(int countDown,IComponent component)
        
{
            
if (countDown > 0)
            
{
                
string target;
                Module[] m 
= component.GetType().Assembly.GetModules();
                target 
= m[0].FullyQualifiedName;
                RunAppAtTime(target, 
new TimeSpan(00, countDown));
                
//Win32Helper.RunAppAtTime(@"/Windows/BubbleBreaker.exe",new TimeSpan(0,0,new TimeSpan(0,countDown,0)));
                component.Dispose();
            }

        }

        
private static void RunAppAtTime(string applicationEvent, DateTime startTime)
        
{
            
long fileTimeUTC = startTime.ToFileTime();
            
long fileTimeLocal = 0;
            SystemTime systemStartTime 
= new SystemTime();
            CoreDLL.FileTimeToLocalFileTime(
ref fileTimeUTC, ref fileTimeLocal);
            CoreDLL.FileTimeToSystemTime(
ref fileTimeLocal, systemStartTime);
            CoreDLL.CeRunAppAtTime(applicationEvent, systemStartTime);

        }


        
private static void RunAppAtTime(string applicationEvent, TimeSpan timeDisplacement)
        
{
            DateTime targetTime 
= DateTime.Now + timeDisplacement;
            RunAppAtTime(applicationEvent, targetTime);
        }

        
#endregion


        
#region---操作模式触发应用程序运行---
        
public static void ApplicationRunModel(string applicationRunPath,Win32ModelType type)
        
{
            
switch (type)
            
{
                
case Win32ModelType .NONE:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_NONE);
                    
break;
                
case Win32ModelType.OFF_AC_POWER:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_OFF_AC_POWER);
                    
break;
                
case Win32ModelType.ON_AC_POWER:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_ON_AC_POWER);
                    
break;
                
case Win32ModelType.SYNC_END:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_SYNC_END);
                    
break;
                
case Win32ModelType .DEVICE_CHANGE:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_DEVICE_CHANGE);
                    
break;
                
case Win32ModelType .IR_DISCOVERED:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_IR_DISCOVERED);
                    
break;
                
case Win32ModelType .MACHINE_NAME_CHANGE:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_MACHINE_NAME_CHANGE);
                    
break;
                
case Win32ModelType .NET_CONNECT:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_NET_CONNECT);
                    
break;
                
case Win32ModelType .NET_DISCONNECT:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_NET_DISCONNECT);
                    
break;
                
case Win32ModelType .RESTORE_END:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_RESTORE_END);
                    
break;
                
case Win32ModelType .RS232_DETECTED:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_RS232_DETECTED);
                    
break;
                
case Win32ModelType .TIME_CHANGE:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_TIME_CHANGE);
                    
break;
                
case Win32ModelType .TZ_CHANGE:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_TZ_CHANGE);
                    
break;
                
case Win32ModelType .WAKEUP:
                    CoreDLL.CeRunAppAtEvent(applicationRunPath, (
int)Win32ModelEnum.NOTFICATION_EVENT_WAKEUP);
                    
break;
            }

        }

        
#endregion


        
#region---关闭电源操作---
        
public static void  ShutDownPower()
        
{
            
int IOCTL_HAL_SHUTDOWN = 0x1012000;
            
int bytesReturned = 0;

            
byte VK_OFF = 0xdf;
            
byte KEYEVENTF_KEYUP = 2;

            CoreDLL.KernelIoControl(IOCTL_HAL_SHUTDOWN, IntPtr.Zero, 
0, IntPtr.Zero, 0ref bytesReturned);

            CoreDLL.keybd_event(VK_OFF, 
000);
            CoreDLL.keybd_event(VK_OFF, 
0, KEYEVENTF_KEYUP, 0);

        }

        
#endregion


        
#region---获取蓝牙状态(PowerOff,Connectable,Discoverable)---
        
public static string GetBluetoothStatue()
        
{
            BluetoothMode mode;
            
int result = CoreDLL.BthGetMode(out mode);
            
if (result != 0)
                
return "Discoverable";
            
else
                
return mode.ToString();
        }


        
#endregion


        
#region---设置蓝牙状态(PowerOff,Connectable,Discoverable)------
        
public static string SetBluetooth(BluetoothMode mode)
        
{
            
int result = CoreDLL.BthSetMode(mode);
            
if (result != 0)
                
return "Discoverable";
            
else
                
return GetBluetoothStatue();
        }

        
#endregion


        
#region---隐藏窗体OK按钮------

        
public const UInt32 SHDB_SHOW = 0x0001;
        
public const UInt32 SHDB_HIDE = 0x0002;
        
public const int GWL_STYLE = -16;
        
public const UInt32 WS_NONAVDONEBUTTON = 0x00010000;
        
/// <summary>
        
/// 隐藏OK按钮
        
/// </summary>
        
/// <param name="hWnd"></param>

        public static void HideDoneButton(IntPtr hWnd)
        
{
            CoreDLL.SHDoneButton(hWnd, SHDB_HIDE);
        }


         
#endregion


        
#region---隐藏窗体X按钮------
        
/// <summary>
        
/// 隐藏X按钮
        
/// </summary>
        
/// <param name="hWnd"></param>

        public static void HideXButton(IntPtr hWnd)
        
{
            UInt32 dwStyle 
= CoreDLL.GetWindowLong(hWnd, GWL_STYLE);

            
if ((dwStyle & WS_NONAVDONEBUTTON) == 0)
                CoreDLL.SetWindowLong(hWnd, GWL_STYLE, dwStyle 
| WS_NONAVDONEBUTTON);
        }

        
#endregion


        
#region---播放WMA文件(第一种方法)------
        
/// <summary>
        
/// 播放WMA文件
        
/// </summary>
        
/// <param name="filePath">播放的文件路径</param>

        public static void PlaySound(string filePath)
        
{
            
if (File.Exists(filePath))
            
{
                CoreDLL.SndPlaySync(filePath, 
0);
            }

        }

        
#endregion


        
#region---播放WMA文件(第二种方法)------
        
/// <summary>
        
/// 播放WMA文件
        
/// </summary>
        
/// <param name="filePath">播放的文件路径</param>

        public static void WCE_PlaySound(string filePath)
        
{
            
if (File.Exists(filePath))
            
{
                CoreDLL.WCE_PlaySound(filePath, IntPtr.Zero, 
0x20001);
            }

        }

        
#endregion


        
#region---设置系统时间------
        
/// <summary>
        
/// 设置系统时间
        
/// </summary>
        
/// <param name="dt">时间格式</param>

        public static void SetDate(DateTime dt)
        
{
            CoreDLL.SYSTEMTIME st;
            st.year 
= (short)dt.Year;
            st.month 
= (short)dt.Month;
            st.dayOfWeek 
= (short)dt.DayOfWeek;
            st.day 
= (short)dt.Day;
            st.hour 
= (short)dt.Hour;
            st.minute 
= (short)dt.Minute;
            st.second 
= (short)dt.Second;
            st.milliseconds 
= (short)dt.Millisecond;
            CoreDLL.SetLocalTime(
ref st);
        }

        
#endregion


        
#region ---获取设备ID------
        
private static Int32 METHOD_BUFFERED = 0;
        
private static Int32 FILE_ANY_ACCESS = 0;
        
private static Int32 FILE_DEVICE_HAL = 0x00000101;

        
private const Int32 ERROR_NOT_SUPPORTED = 0x32;
        
private const Int32 ERROR_INSUFFICIENT_BUFFER = 0x7A;

        
private static Int32 IOCTL_HAL_GET_DEVICEID =
            ((FILE_DEVICE_HAL) 
<< 16| ((FILE_ANY_ACCESS) << 14)
            
| ((21<< 2| (METHOD_BUFFERED);

        
public static string GetDeviceID()
        
{
            
// Initialize the output buffer to the size of a 
            
// Win32 DEVICE_ID structure.
            byte[] outbuff = new byte[20];
            Int32 dwOutBytes;
            
bool done = false;

            Int32 nBuffSize 
= outbuff.Length;

            
// Set DEVICEID.dwSize to size of buffer.  Some platforms look at
            
// this field rather than the nOutBufSize param of KernelIoControl
            
// when determining if the buffer is large enough.
            BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0);
            dwOutBytes 
= 0;

            
// Loop until the device ID is retrieved or an error occurs.
            while (!done)
            
{
                
if (CoreDLL.KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero,
                    
0, outbuff, nBuffSize, ref dwOutBytes))
                
{
                    done 
= true;
                }

                
else
                
{
                    
int error = Marshal.GetLastWin32Error();
                    
switch (error)
                    
{
                        
case ERROR_NOT_SUPPORTED:
                            
break;

                        
case ERROR_INSUFFICIENT_BUFFER:

                            
// The buffer is not big enough for the data.  The
                            
// required size is in the first 4 bytes of the output
                            
// buffer (DEVICE_ID.dwSize).
                            nBuffSize = BitConverter.ToInt32(outbuff, 0);
                            outbuff 
= new byte[nBuffSize];

                            
// Set DEVICEID.dwSize to size of buffer.  Some
                            
// platforms look at this field rather than the
                            
// nOutBufSize param of KernelIoControl when
                            
// determining if the buffer is large enough.
                            BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0);
                            
break;

                        
default:
                            
break;
                    }

                }

            }


            
// Copy the elements of the DEVICE_ID structure.
            Int32 dwPresetIDOffset = BitConverter.ToInt32(outbuff, 0x4);
            Int32 dwPresetIDSize 
= BitConverter.ToInt32(outbuff, 0x8);
            Int32 dwPlatformIDOffset 
= BitConverter.ToInt32(outbuff, 0xc);
            Int32 dwPlatformIDSize 
= BitConverter.ToInt32(outbuff, 0x10);
            StringBuilder sb 
= new StringBuilder();

            
for (int i = dwPresetIDOffset;
                i 
< dwPresetIDOffset + dwPresetIDSize; i++)
            
{
                sb.Append(String.Format(
"{0:X2}", outbuff[i]));
            }


            sb.Append(
"-");

            
for (int i = dwPlatformIDOffset;
                i 
< dwPlatformIDOffset + dwPlatformIDSize; i++)
            
{
                sb.Append(String.Format(
"{0:X2}", outbuff[i]));
            }

            
return sb.ToString();
        }

        
#endregion


        
#region ---输入面板显示------
        
private const uint SIPF_OFF = 0x0;
        
private const uint SIPF_ON = 0x1;
        
public static void SipShowIM(uint sip)
        
{
            CoreDLL.SipShowIM(SIPF_ON);
        }

        
#endregion


        
#region ---输入面板隐藏------
        
public static void HideSip(uint sip)
        
{

            CoreDLL.SipShowIM(SIPF_OFF);
        }

        
#endregion


        
#region ----读注册表GetOwner获取手机用户名----
        
//public static string GetOwner
        
//{
        
//    get
        
//    {
        
//        //读取手机主人姓名
        
//        RegistryKey key = Registry.CurrentUser.OpenSubKey(@"ControlPanel/Owner");
        
//        object val = key.GetValue("Name");
        
//        if (val == null)
        
//            return "肖百刚";
        
//        key.Close();
        
//        return (string)val;
        
//    }
        
//}
        #endregion


    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值