pneau
Messages postés
258
Date d'inscription
mercredi 21 avril 2004
Statut
Membre
Dernière intervention
27 octobre 2010
5
22 nov. 2007 à 13:42
oui, moi aussi, je voulais faire cela mais le probleme c'est que pour gérer un périph connecté sur USB ou Réseau, tu fais comment ? perso je n'ai pas trouvé... je n'ai peut etre pas bien cherché. Bref, pour des soucis de délais de réalisation, je me suis retranché sur ActiveSync.
donc, j'ai utilisé les fonctions de la dll RAPI. ci dessous les déclarations des api utilisées.
[
StructLayout(
LayoutKind.Explicit)]
struct
RAPIINIT{
[
FieldOffset(0)]
public
int cbSize;[
FieldOffset(4)]
public
IntPtr heRapiInit;[
FieldOffset(8)]
public
int hrRapiInit;};
[
StructLayout(
LayoutKind.Sequential, CharSet =
CharSet.Unicode)]
struct
CE_FIND_DATA{
public
int dwFileAttributes;
public
int ftCreationTime_LowDateTime;
public
int ftCreationTime_HighDateTime;
public
int ftLastAccessTime_LowDateTime;
public
int ftLastAccessTime_HighDateTime;
public
int ftLastWriteTime_LowDateTime;
public
int ftLastWriteTime_HighDateTime;
public
int nFileSizeHigh;
public
int nFileSizeLow;
public
int dwReserved0;[
MarshalAs(
UnmanagedType.ByValTStr, SizeConst = 260)]
public
string cFileName;};
[
DllImport("kernel32.dll", SetLastError true, ExactSpelling
true)]
private
static
extern
Int32 WaitForSingleObject (
IntPtr hHandle,
Int32 dwMilliseconds);
[
DllImport(
"rapi.dll", SetLastError =
true)]
private
static
extern
int CeRapiInitEx (
ref
RAPIINIT pRapiInit);[
DllImport(
"rapi.dll", SetLastError =
true)]
private
static
extern
int CeRapiUninit();[
DllImport(
"rapi.dll", SetLastError =
true,CharSet=
CharSet.Unicode)]
private
static
extern
int CeFindFirstFile(
string lpFileName,
ref
CE_FIND_DATA lpFindFileData);[
DllImport("rapi.dll", SetLastError true, CharSet
CharSet.Unicode)]
private
static
extern
int CeFindNextFile(
int handle,
ref
CE_FIND_DATA lpFindFileData);[
DllImport(
"rapi.dll")]
private
static
extern
bool CeFindClose(
int handle);[
DllImport("rapi.dll", SetLastError true, CharSet
CharSet.Unicode)]
private
static
extern
int CeCopyFile(
string lpExistingFileName,
string lpNewFileName,
bool bFailIfExists);[
DllImport(
"rapi.dll", SetLastError =
true, CharSet=
CharSet.Unicode)]
private
static
extern
bool CeDeleteFile(
string lpFileName);[
DllImport(
"rapi.dll", SetLastError =
true)]
private
static
extern
int CeRapiGetError();[
DllImport(
"rapi.dll", SetLastError =
true)]
private
static
extern
int CeGetLastError();[
DllImport(
"rapi.dll", CharSet=
CharSet.Unicode)]
private
static
extern
int CeCreateFile(
string lpFileName,
uint dwDesiredAccess,
int dwShareMode,
int lpSecurityAttributes,
int dwCreationDisposition,
int dwFlagsAndAttributes,
int hTemplateFile);[
DllImport(
"rapi.dll", CharSet =
CharSet.Unicode)]
private
static
extern
int CeReadFile(
int hFile,
byte[] lpBuffer,
int nNumberOfbytesToRead,
out
int lpNumberOfbytesRead,
int lpOverlapped);[
DllImport(
"rapi.dll")]
private
static
extern
uint CeGetFileSize(
int hFile,
ref
uint lpFileSizeHigh);[
DllImport(
"rapi.dll")]
private
static
extern
int CeCloseHandle(
int hFile);[
DllImport(
"rapi.dll", CharSet =
CharSet.Unicode)]
private
static
extern
uint CeRegOpenKeyEx(
uint HKEY,
string lpSubKey,
int ulOptions,
uint samDesired,
out
uint phkResult);[
DllImport(
"rapi.dll", CharSet =
CharSet.Unicode)]
private
static
extern
int CeRegCreateKeyEx(
uint hKey,
string lpKeyName,
int lpReserved,
string dwType,
int dwOptions,
int samDesired,
int lpSecurityAttributes,
out
uint phkResult,
out
uint lpdwDisposition);[
DllImport(
"rapi.dll", CharSet =
CharSet.Unicode)]
private
static
extern
int CeRegSetValueEx(
uint hKey,
string lpValueName,
int lpReserved,
int dwType,
byte[] lpData,
int cbData);
[
DllImport(
"rapi.dll", CharSet =
CharSet.Unicode)]
private
static
extern
uint CeRegQueryValueEx(
uint hKey,
string lpValueName,
int lpReserved,
ref
int lpType,
byte[] lpData,
ref
int lpchData);
[
DllImport(
"rapi.dll")]
private
static
extern
int CeRegCloseKey(
uint hkey);
Pat
Don't Worry , Be Happy