4 pagesV  < 1 2 3 4 > »  
 
REPLY
> Some sources.
-QwertY-
Message#1
17.10.05, 21:33
Social network? No, have not heard!
*********
[offline]

Group: Admins
Messages 4979
Check in: 12.08.06

Reputation:-  0  +

����� ����� ����������� �������� ���� ����� ��������, ������� � �.�.
�� ��� ������ ����-�����...
download

S_K
Message#22
24.03.07, 23:38
Guru
*********
[offline]

Group: Developers
Messages 3718
Check in: 13.07.05
Nokia Lumia 710

Reputation:-  482  +

-QwertY-: I'll give you +. Really useful code!

Turning on / off radio devices on the example of WIFI

typedef enum _DEVTYPE
{
DEV_WIFI = 1,
DEV_PHONE,
DEV_BLUETOOTH,
} DEVTYPE;





struct RDD
{
RDD (): pszDeviceName (NULL), pNext (NULL), pszDisplayName (NULL) {}
~ RDD () {LocalFree (pszDeviceName); LocalFree (pszDisplayName); }
LPTSTR pszDeviceName;
LPTSTR pszDisplayName;
DWORD dwState;
DWORD dwDesired;
DEVTYPE DeviceType;
RDD * pNext;
};


typedef HRESULT (* TPChangeRadioState) (RDD * pDev, DWORD dwState, SAVEACTION sa); // 273
typedef HRESULT (* TPGetWirelessState) (BOOL * bState); // 277
typedef HRESULT (* TPGetWirelessDevices) (RDD ** pDevices, DWORD dwFlags); // 276
typedef HRESULT (* TPChangeWirelessState) (BOOL bOn); // 278
typedef void (* TPFreeDeviceList) (RDD * pRoot); // 280


int setwifistate (int state)
{

BOOL bState = false;
HRESULT res = E_FAIL;
TPGetWirelessDevices pTPGetWirelessDevices;
TPFreeDeviceList pTPFreeDeviceList;
TPChangeRadioState pTPChangeRadioState;
TPGetWirelessState pTPGetWirelessState;
TPChangeWirelessState pTPChangeWirelessState;


HMODULE m = LoadLibrary (L "ossvcs.dll");

if (m)
{
�
�
pTPGetWirelessDevices = (TPGetWirelessDevices) GetProcAddress (m, MAKEINTRESOURCE (276));
pTPFreeDeviceList = (TPFreeDeviceList) GetProcAddress (m, MAKEINTRESOURCE (280));
pTPChangeRadioState = (TPChangeRadioState) GetProcAddress (m, MAKEINTRESOURCE (273));
pTPGetWirelessState = (TPGetWirelessState) GetProcAddress (m, MAKEINTRESOURCE (277));
pTPChangeWirelessState = (TPChangeWirelessState) GetProcAddress (m, MAKEINTRESOURCE (278));
�
�
RDD * pDevice = NULL;
RDD * pTD;
�
if (pTPChangeWirelessState && pTPGetWirelessState && pTPGetWirelessDevices && pTPFreeDeviceList && pTPChangeRadioState)
�{
�
if (state == 1)
� {
pTPGetWirelessState (& bState);
if (bState == false)
pTPChangeWirelessState (true);
� �
� �
� }
�
�
�
res = pTPGetWirelessDevices (& pDevice, 0);
�
if (pDevice)
� {
� �
pTD = pDevice;
� �
� �
while (pTD)
� �{
� �
switch (pTD-> DeviceType)
� � {
� � �
case DEV_WIFI:

� � �
if (pTD-> dwState! = state)
� � �{
res = pTPChangeRadioState (pTD, state, 2);
� � �}
else
res = S_OK;
break;
� � �
� � �
default:
break;
� � �
� � }
� �
pTD = pTD-> pNext;
� �
� �}
� �
pTPFreeDeviceList (pDevice);
� }
�
�}
�
FreeLibrary (m);
�
}


return res == S_OK;
}


known glitch -
on some devices after the soft preset, some radio devices (WIFI) are not seen until you get them built-in.


--------------------
SKKV Software
-QwertY-
Message#23
07.06.07, 03:15
Social network? No, have not heard!
*********
[offline]

Group: Admins
Messages 4979
Check in: 12.08.06

Reputation:-  0  +

Well, well .... I'll try to lay out a little snack.
Everyone knows that there are no built-in ini file reading functions on the package? such as GetPrivateProfileString and WritePrivateProfileString ... I think this will help ....
So far we are only reading, in principle it is possible to make oneself, if you modify it with a file ....
It reads only ANSI encoding, hands did not reach unicode, but it is not difficult to make it ...

PS Yuzayu only malloc and free because of some glitch (maybe just me so) with the realloc function.
PPS tried to foresee everything that is possible ... redundant, but nothing can be done ...

Attached files

Attached filec_ini.rar(2.67 KB)


--------------------
People like me here, people like you here. They don’t go around here, they don’t hide their eyes.Compromise is not for us!
© Alice - Compromise
Winner of the First Prizesavagemessiahzine.comin the nomination of the Hero of the Forum!
Prize winnersavagemessiahzine.comin the nomination "Master'07"
ZoFF
Message#24
08.06.07, 08:53
Local
*****
[offline]

Group: Developers
Messages 101
Check in: 11.04.07
Samsung Galaxy Note 3 LTE SM-N9005

Reputation:-  70  +

Log file maintenance:
void Write_LOG (CHAR * szLOG_TEXT)
{
SYSTEMTIME st;
FILE * hFile;
GetLocalTime (& st);
hFile = _wfopen (TEXT ("\\ log_.txt"), L "a");
fprintf (hFile, "[% d:% d:% d]", st.wHour, st.wMinute, st.wSecond);
fprintf (hFile, szLOG_TEXT);
fprintf (hFile, "\ n");
fflush (hFile);
fclose (hFile);
}


To call:
Write_LOG ("logging in File");


Post has been edited-QwertY- - 23.02.08, 21:59
ZoFF
Message#25
08.06.07, 17:44
Local
*****
[offline]

Group: Developers
Messages 101
Check in: 11.04.07
Samsung Galaxy Note 3 LTE SM-N9005

Reputation:-  70  +

Switching the device on and off programmatically:
#include "windows.h"
#define QUERYESCSUPPORT 8
#define GETVFRAMEPHYSICAL 6144
#define GETVFRAMELEN 6145
#define DBGDRIVERSTAT 6146
#define SETPOWERMANAGEMENT 6147
#define GETPOWERMANAGEMENT 6148

typedef enum _VIDEO_POWER_STATE {
VideoPowerOn = 1,
VideoPowerStandBy,
VideoPowerSuspend,
VideoPowerOff
} VIDEO_POWER_STATE, * PVIDEO_POWER_STATE;
typedef struct _VIDEO_POWER_MANAGEMENT {
ULONG Length;
ULONG DPMSVersion;
ULONG PowerState;
} VIDEO_POWER_MANAGEMENT, * PVIDEO_POWER_MANAGEMENT;


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR pszCommandLine, int nCommandShow)
{
HDC gdc;
int iESC = SETPOWERMANAGEMENT;
gdc = GetDC (NULL);
if (ExtEscape (gdc, QUERYESCSUPPORT, sizeof (int), (LPCSTR & iESC, 0, NULL) == 0)
MessageBox (NULL, L "Sorry, your Pocket PC does not support DisplayOff", L "Err", MB_OK);
else
{
VIDEO_POWER_MANAGEMENT vpm;
vpm.Length = sizeof (VIDEO_POWER_MANAGEMENT);
vpm.DPMSVersion = 0x0001;
vpm.PowerState = VideoPowerOff;
// Power off the display
ExtEscape (gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) & vpm, 0, NULL);
Sleep (5000);
vpm.PowerState = VideoPowerOn;
// Power on the display
ExtEscape (gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) & vpm, 0, NULL);
ReleaseDC (NULL, gdc);
�}
return 0;
}
ZoFF
Message#26
28.06.07, 19:35
Local
*****
[offline]

Group: Developers
Messages 101
Check in: 11.04.07
Samsung Galaxy Note 3 LTE SM-N9005

Reputation:-  70  +

The example shows how to connect to the Internet, how to read the registry branch, and how to run the file.
In particular, this program - it finds where the program is installed MChat, connects to the Internet, and launches Mchat

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
wchar_t rezerva [1024];
HKEY Regentry;
DWORD dwSize = 1020, dwType;
SHELLEXECUTEINFO sei = {0};

RegOpenKeyEx (HKEY_LOCAL_MACHINE, L "SOFTWARE \\ Apps \\ mGSLab.com mChat", 0, KEY_QUERY_VALUE, & Regentry);
RegQueryValueEx (Regentry, L "InstallDir", NULL, & dwType, (unsigned char *) & rezerva, & dwSize);

CONNMGR_CONNECTIONINFO sConInfo;
HANDLE phWebConnection;
DWORD pdwStatus;

memset (& sConInfo, 0, sizeof (CONNMGR_CONNECTIONINFO));
sConInfo.cbSize = sizeof (CONNMGR_CONNECTIONINFO);
sConInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
sConInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
sConInfo.dwFlags = 0;
sConInfo.bExclusive = FALSE;
sConInfo.bDisabled = FALSE;
sConInfo.guidDestNet = IID_DestNetInternet;
ConnMgrEstablishConnectionSync (& sConInfo, & phWebConnection, 60000, & pdwStatus);

Sleep (3000);

sei.cbSize = sizeof (SHELLEXECUTEINFO);
wcscat (rezerva, L "\\ mChat.exe");
sei.lpFile = rezerva;
ShellExecuteEx (& sei);

return 0;
}
std.denis
Message#27
15.09.07, 14:29
Old resident
*******
[online]

Group: Developers
Messages 956
Check in: 09.03.06

Reputation:-  103  +

We can someone be useful. logging:
TCHAR * g_szDebugLog = _T ("/ someApplication.log");
CRITICAL_SECTION g_csDebugLog;
void debugLog (char * str)
{
EnterCriticalSection (& g_csDebugLog);
FILE * fpDebugLog = _tfopen (g_szDebugLog, _T ("a"));
if (fpDebugLog) {
SYSTEMTIME ltm;
GetLocalTime (& ltm);
fprintf (fpDebugLog, "% 02d:% 02d:% 02d,% 03d |", ltm.wHour, ltm.wMinute, ltm.wSecond, ltm.wMilliseconds);
fputs (str, fpDebugLog);
fputs ("\ n", fpDebugLog);
fclose (fpDebugLog);
}
LeaveCriticalSection (& g_csDebugLog);
}

void debugLogf (const char * fmt, ...)
{
va_list vararg;
va_start (vararg, fmt);
const size_t maxsz = 1024;
char * str = (char *) alloca (maxsz);
_vsnprintf (str, maxsz, fmt, vararg);
va_end (vararg);

debugLog (str);
}
(...)
// at the beginning of the program you need to initialize g_csDebugLog
InitializeCriticalSection (& g_csDebugLog);
// usage example
debugLogf ("some operation failed:% d", GetLastError ());
StSlam
Message#28
08.11.07, 14:20
Local
*****
[offline]

Group: Friendssavagemessiahzine.com
Messages 325
Check in: 05.10.05
Samsung Galaxy Note 3 SM-N900

Reputation:-  33  +

We send USSD and accept the balance (without balun tacking)
// output to file
void __fastcall DUMP (BYTE * cstr, LONG length)
{
DWORD dwRet;
HANDLE hDumpFile = CreateFile (_T ("dbg.txt"), GENERIC_WRITE, FILE_SHARE_READ, NULL,
OPEN_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
SetFilePointer (hDumpFile, 0, NULL, FILE_END);
WriteFile (hDumpFile, cstr, length, & dwRet, NULL);
WriteFile (hDumpFile, "\ r \ n", 2, & dwRet, NULL);
CloseHandle (hDumpFile);
}

// Response Handler
void CALLBACK NotifyCallback (DWORD dwCode, const void * lpData, DWORD cbData, DWORD dwParam)
{
RILSUPSERVICEDATA * rsd;
switch (dwCode)
{
case RIL_NOTIFY_SUPSERVICEDATA:
// MessageBox (NULL, _T ("NotifyCallback"), _ T (""), MB_OK);
rsd = (RILSUPSERVICEDATA *) lpData;
DUMP ((BYTE *) rsd-> pbData, rsd-> cbSize-12);
break;
default:
;
}
}

// availability is necessary for proper operation
void CALLBACK ResultCallback (DWORD dwCode, HRESULT hrCmdID, const void * lpData, DWORD cbData, DWORD dwParam)
{
}


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HRIL hRil;
HRESULT hr;
WCHAR psnd] = _T ("* 110 * 10 #"); // the request that will send the phone modem, the balance is requested from me just so

DWORD len = lstrlen (psnd);
// initialization of work with the telephone part
// handlers are assigned the completion of processing and response
// assigned to service only USSD requests
hr = RIL_Initialize (1, ResultCallback, NotifyCallback, RIL_NCLASS_SUPSERVICE, dwParam, & hRil);
if (hr! = S_OK)
MessageBox (NULL, _T ("Err RIL_Initialize"), _ T ("Err"), MB_OK);

hr = RIL_SendSupServiceData (hRil, (BYTE *) psnd, len);
if (hr <0)
MessageBox (NULL, _T ("RIL_SendSupServiceData"), _ T ("Err"), MB_OK);
Sleep (2500);
RIL_Deinitialize (hRil);
}


--------------------
N900
Outcast-d.o.b
Message#29
06.01.08, 06:15
Guru
*********
[offline]

Group: Friendssavagemessiahzine.com
Messages 2381
Check in: 07.02.06
Fujitsu-Siemens Loox 720

Reputation:-  123  +

Not mine, but it can be useful for programming drivers for wifi;)

Added @ 06.01.2008, 06:18

a wide range of supported types of chipsets and adapters, including USB!

Attached files

Attached filePacketCE.zip(174.76 KB)


--------------------
Outcast-death_of_beat ...
Hey! Catch me - receive a prize!
Greetings the users, I look you have become wiser?
Giny
Message#30
10.03.08, 15:15
Visitor
**
[offline]

Group: Active users
Messages 29
Check in: 10.12.07

Reputation:-  4  +

Nice section. Here is my contribution. Can someone use AES 128/192/256 encryption (files in the attachment) ...

Attached files

Attached fileaes.rar(5.2 KB)
Inpropagation
Message#31
14.03.08, 13:27
Local
*****
[offline]

Group: Friendssavagemessiahzine.com
Messages 256
Check in: 14.06.07
Samsung Omnia II GT-I8000

Reputation:-  58  +

My small project SizeView - view the file system with the output of the full size of the folders and attached files to them.
C #, .NET 2.0
A good example for those who are just starting to write something in C #.
Sample code for recursive browsing of the file system.
An example of the implementation of a custom formatter is ICustomFormatter, IFormatProvider

Attached files

Attached fileSizeView_src2.rar(13.61 KB)
Starov
Message#32
27.03.08, 00:31
Local
*****
[offline]

Group: Friendssavagemessiahzine.com
Messages 391
Check in: 02.03.08
Samsung Galaxy S8 Exynos

Reputation:-  23  +

TASTY, DESCRIBING THIS YOU WILL NOT FIND ANYWHERE !!!
everyone knows such a thing "Shared Internet"? or Inet Sharing ..... (Internet connection on a computer via a communicator .. :-))
The idea is this: for example, I have a night bezlimitka on a megaphone, but the Internet has the ability to constantly hang .... so you need to restart the device and again steal the Internet to make the rocking chair work again ...
I also post the compiled source .. which is tuned to the megaphone .... you just need to plug in the cable and that's it ..))) Attention! First you need to set up a megaphone Internet! otherwise, the comun will go to the eternal software rezet :-D (not stashno principle in task manager can manage to cut off the program after rebooting the device ...)


DWORD WINAPI InternetSharingEnable (int a, LPWSTR b, int c, LPWSTR d)
{
typedef DWORD (WINAPI * ISE) (int a, LPWSTR b, int c, LPWSTR d);
ISE f = (ISE) GetProcAddress (LoadLibrary (L "intshare.dll"), L "InternetSharingEnable");
return f (a, b, c, d);
}


BOOL MakeConnection ()
{
BOOL Ret = FALSE;

WaitForSingleObject (ConnMgrApiReadyEvent (), INFINITE);

Sleep (5000);
if (InternetSharingEnable (0, L "USB", 3, L "Megafon-Internet") == 0)
{
Ret = TRUE;
}
else
{
Sleep (10,000); if (InternetSharingEnable (0, L "USB", 3, L "Megafon-Internet") == 0) Ret = TRUE;
}

return Ret;
}


Of course, working with this function is much more difficult, but we will not complicate it ...
The complete source is included ... the prog also checks the stability of the connection of the compound ....

Attached files

Attached filegpgstool.rar(13.74 KB)


Post has been editedStarov - 27.03.08, 00:35


--------------------
CallsRecorder - the latest version is always on the official website of the program ....
Murav
Message#33
09.04.08, 20:58
Guru
*********
[offline]

Group: Developers
Messages 2817
Check in: 17.09.07
Asus MyPal A636N

Reputation:-  197  +

Starov,
HereI posted my program (andits source) to control internet sharing, which works through the same functions. There is also a description of all parameters (parameters specified in the program are passed directly to intshr) andinternet sharing installation, if it is not in the firmware initially.
Murav
Message#34
09.04.08, 21:30
Guru
*********
[offline]

Group: Developers
Messages 2817
Check in: 17.09.07
Asus MyPal A636N

Reputation:-  197  +

Here is an example of a touchscreen filter driver.

To install the driver, install SdkCerts.cab, copy the driver to \ Windows and replace HKLM \ HARDWARE \ DEVICEMAP \ TOUCH \ DriverName in the registry to TouchTest.dll, and write the old value to HKLM \ HARDWARE \ DEVICEMAP \ TOUCH \ OrigDriverName.

After compilation, the driver must be signed with sign.bat. In the attached project for VS2005 this is already configured.

The tchddi.h file is taken from the WinCe 5.0 Platform Builder.

Driver updated - fixed bug with hanging on resuming from sleep mode.

Attached files

Attached fileTouchTest.zip(65.38 KB)


Post has been editedMurav - 05.08.08, 18:42
YouROK85
Message#35
07.05.08, 08:24
Guru
*********
[offline]

Group: Developers
Messages 2787
Check in: 06.04.07
Meizu Pro 6 Plus 64GB

Reputation:-  517  +

The code for the function of inclusion, (wake up)
like msdn stole

#include
#include


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE phInst, LPWSTR, int)
{
HANDLE hEvent;
HANDLE hNotify;
BOOL bTriggered;
SYSTEMTIME curSysTime;
SYSTEMTIME endSysTime;
CE_NOTIFICATION_TRIGGER trigger;

bTriggered = FALSE;
trigger.dwSize = sizeof (CE_NOTIFICATION_TRIGGER);

// System event notification
trigger.dwType = CNT_EVENT;

// The device disconnected from a network
trigger.dwEvent = NOTIFICATION_EVENT_WAKEUP; // here you can put another value.

// this will be a named event
trigger.lpszApplication = _T ("\\\\. \\ Notifications \\ NamedEvents \\ MyTestEvent \ 0");
trigger.lpszArguments = NULL;

// set start and end of notification period
GetSystemTime (& curSysTime);
endSysTime = curSysTime;
endSysTime.wYear = endSysTime.wYear + 20;
trigger.stStartTime = curSysTime;
trigger.stEndTime = endSysTime;
MessageBox (0, (L "Program is run."), NULL, 0);
// create a named event
hEvent = CreateEvent (NULL, FALSE, FALSE, _T ("MyTestEvent \ 0"));

// if named event was created
if (hEvent)
{
// create user notification
hNotify = CeSetUserNotificationEx (0, & trigger, NULL);

// if user notification was created
if (hNotify)
{
// wait for event to be triggered
while (! bTriggered)
{

// wait for my event
if (WaitForSingleObject (hEvent, INFINITE)! = WAIT_OBJECT_0)
{
MessageBox (0, (L "Unknown Event signaled"), NULL, 0);
}
else
{
MessageBox (0, (L "My Event signaled"), NULL, 0);
// my event was triggered
bTriggered = TRUE;
}
}
}
else
{
MessageBox (0, (L "CeSetUserNotificationEx failed"), NULL, 0);
}

}
else
{
MessageBox (0, (L "CreateEvent failed"), NULL, 0);
}
CeClearUserNotification (hNotify);
}


--------------------
Torrserve
M3U8 Loader
Thanks to everyone who supported me.
danila_ru
Message#36
27.06.08, 12:04
Prof Reminder
********
[offline]

Group: Developers
Messages 1306
Check in: 09.01.07
Samsung Galaxy S7 SM-G930FD

Reputation:-  302  +

Found an error in the exampleprocess quenchingBOOL EndProcess function (LPWSTR procname):

InsteadCloseHandle (hProcessSnap) should use CloseToolhelp32Snapshot (hProcessSnap) . MSDN clearly warns - otherwise there will be precious memory leaks


--------------------
Ntkiller
Message#37
06.07.08, 08:41
Local
*****
[offline]

Group: Developers
Messages 255
Check in: 17.08.07

Reputation:-  48    +

Object for logging

Logger.h
#pragma once

class Logger
{
public:
Logger (void);
Logger (LPWSTR);
void setFileName (LPWSTR);
void log (const char *);
void logf (const char *, ...);
~ Logger (void);
private:
CRITICAL_SECTION cs;
LPWSTR filename;
};


Logger.cpp
#include "StdAfx.h"
#include "Logger.h"

Logger :: Logger (void): filename (NULL)
{
InitializeCriticalSection (& cs);
}

Logger :: Logger (LPWSTR logname)
{
InitializeCriticalSection (& cs);
int len ​​= wcslen (logname);
if (len> 1)
{
this-> filename = new WCHAR [len];
wcscpy (this-> filename, logname);
} else {
this-> filename = NULL;
}
}

void Logger :: setFileName (LPWSTR logname)
{
if (this-> filename! = NULL)
{
delete] this-> filename;
this-> filename = NULL;
}

int len ​​= wcslen (logname);
if (len> 1)
{
this-> filename = new WCHAR [len];
wcscpy (this-> filename, logname);
} else {
this-> filename = NULL;
}

}

void Logger :: log (const char * str)
{
EnterCriticalSection (& cs);
FILE * fpLog = _tfopen (this-> filename, TEXT ("a"));
if (fpLog)
{
SYSTEMTIME lt;
GetLocalTime (& lt);
fprintf (fpLog, "[% 02d:% 02d:% 02d]", lt.wHour, lt.wMinute, lt.wSecond);
fputs (str, fpLog);
fputs ("\ n", fpLog);
fclose (fpLog);
}
LeaveCriticalSection (& cs);
}

void Logger :: logf (const char * str, ...)
{
va_list vararg;
va_start (vararg, str);
char * logStr = new CHAR [1024];
_vsnprintf (logStr, 1024, str, vararg);
va_end (vararg);
this-> log (logStr);
delete] logStr;
}

Logger :: ~ Logger (void)
{
if (this-> filename! = NULL)
{
delete] this-> filename;
}
}


Usage example
//Initialization
Logger * g_Log = NULL;
g_Log = new Logger (L "/testfile.log");

//Using
g_Log-> log ("TEST");
g_Log-> logf ("TEST:% d", 123);

// Release
delete g_Log;


P.S. When writing, I looked at the code from std.denis -Some sources.I noticed an error (I think so) - if you call debugLogf, then memory is allocated there, and after the output to the log it is not released ... Perhaps the loss ...
YouROK85
Message#38
05.08.08, 14:14
Guru
*********
[offline]

Group: Developers
Messages 2787
Check in: 06.04.07
Meizu Pro 6 Plus 64GB

Reputation:-  517  +

Creating buttons in the window can be other controls
in resources to add
#define IDC_MyBUTTON 5000

#include

#define but 7

int CreateWin (HWND hwnd)
{
LPCWSTR ButN [but] = {L "Knop1", L "Knop2", L "Knop3",
L "Knop4", L "Knop5", L "Knop6", L "Knop7"};
int fx = GetSystemMetrics (SM_CXFULLSCREEN) -10;
int fy = GetSystemMetrics (SM_CYFULLSCREEN) -10;
int yd = fy / 25;
int n = but;
for (int i = 0; i {
CreateWindow (L "button", ButN [i], WS_CHILD | WS_VISIBLE,
10, (fy / n) * i + yd, fx-10, fy / n-yd, hwnd, HMENU (IDC_MyBUTTON + i), NULL, NULL);
}
return 0;
}


Phone events

#include
#include

typedef struct tagLINEINFO
{
HLINE hLine;
BOOL bVoiceLine;
DWORD dwAPIVersion;
DWORD dwNumOfAddress;
DWORD dwPermanentLineID;
TCHAR szLineName [256];

} LINEINFO, * LPLINEINFO;

VOID CALLBACK lineCallbackFunc (DWORD hDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);

DWORD dwReturn;
HLINEAPP g_hLineApp = NULL;
DWORD g_dwNumDevs = 0;
LPLINEINFO * g_lpLineInfo = NULL;
DWORD dwLineID, dwAPIVersion;
LPHLINE g_lphLine;

HWND g_hwndDial;
Hwnd g_hwnd;
int StatPhone;

int GetStatus ()
{
return StatPhone;
}

void SetStatus (int st)
{
StatPhone = st;
}

DWORD InitTAPI (HINSTANCE hInstance, HWND hwnd)
{
g_hWnd = hwnd;
StatPhone = 0;
dwReturn = lineInitialize (& g_hLineApp, hInstance, (LINECALLBACK) lineCallbackFunc, L "Prog", & g_dwNumDevs);
if (! g_dwNumDevs) return LINEERR_NODEVICE;
if (dwReturn) return dwReturn;

if (! (g_lphLine = (LPHLINE) LocalAlloc (LPTR, sizeof (HLINE) * g_dwNumDevs)))
return LINEERR_NOMEM;

for (dwLineID = 0; dwLineID {
if (! lineNegotiateAPIVersion (
g_hLineApp,
dwLineID,
TAPI_CURRENT_VERSION,
TAPI_CURRENT_VERSION,
& dwAPIVersion,
NULL))
{
dwReturn = lineOpen (
g_hLineApp,
dwLineID,
g_lphLine,
dwAPIVersion
0,
0,
LINECALLPRIVILEGE_OWNER,
LINEMEDIAMODE_INTERACTIVEVOICE,
Null
);

g_lphLine ++;
}
}
return dwReturn;
}

void TAPIUnInit ()
{

DWORD i, dwReturn;
LPHLINE lphLine;

lphLine = g_lphLine;

for (i = 0; i {
if (* lphLine)
dwReturn = lineClose (* lphLine);
lphLine ++;
}

if (g_hLineApp)
lineShutdown (g_hLineApp);

LocalFree ((HLOCAL) g_lphLine);
}

VOID CALLBACK lineCallbackFunc (DWORD dDvice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
switch (dwMsg)
{
case LINE_CALLSTATE:
switch (dwParam1)
{
case LINECALLSTATE_OFFERING: // received call
StatPhone = 2;
break;

case LINECALLSTATE_CONNECTED:
StatPhone = 4;
break;

case LINECALLSTATE_BUSY:
case LINECALLSTATE_IDLE:
case LINECALLSTATE_DISCONNECTED:
StatPhone = 3;
break;
}
default:
break;
}

}


Post has been edited# YouROK # - 12.08.08, 15:03


--------------------
Torrserve
M3U8 Loader
Thanks to everyone who supported me.
constv
Message#39
07.08.08, 09:13
I'm Android
*********
[offline]

Group: Developers
Messages 3665
Check in: 06.04.07
Xiaomi Mi 5

Reputation:-  533  +

Example of intercepting incoming SMS using IMAPIAdviseSink

In my opinion, this method is preferable to IMailRuleClient.

So, we will declare and implement the class, the successor of IMAPIAdviseSink

class CMAPIAdviseSink: public IMAPIAdviseSink
{
public:
CMAPIAdviseSink ();
~ CMAPIAdviseSink ();

// IUnknown
STDMETHOD (QueryInterface) (REFIID iid, LPVOID * ppv);
STDMETHOD_ (ULONG, AddRef) ();
STDMETHOD_ (ULONG, Release) ();

// IMAPIAdviseSink
STDMETHOD_ (ULONG, OnNotify) (ULONG cNotif, LPNOTIFICATION lpNotifications);


private:
long m_cRef;
};


I will give the implementation of the OnNotify method later

CMAPIAdviseSink :: CMAPIAdviseSink ()
{
m_cRef = 1;
}

CMAPIAdviseSink :: ~ CMAPIAdviseSink ()
{
}

HRESULT CMAPIAdviseSink :: QueryInterface (REFIID rif, void ** ppobj)
{
HRESULT hr = E_NOINTERFACE;

if (! ppobj)
{
return E_INVALIDARG;
}

* ppobj = NULL;
if ((rif == IID_IUnknown) || (rif == IID_IMAPIAdviseSink))
{
* ppobj = (LPVOID) this;
}

if (* ppobj)
{
((LPUNKNOWN) * ppobj) -> AddRef ();
hr = S_OK;
}

return hr;
}

ULONG CMAPIAdviseSink :: AddRef ()
{
return InterlockedIncrement (& m_cRef);
}

ULONG CMAPIAdviseSink :: Release ()
{
InterlockedDecrement (& m_cRef);

int nLocal = m_cRef;

if (! m_cRef)
{
delete this;
}

return nLocal;
}



We initialize MAPI and get a pointer to the IMAPISession interface, error handling is omitted for brevity


ICEMAPISession * pSession = NULL;

....
HRESULT hr;
....
hr = MAPIInitialize (NULL);
hr = MAPILogonEx (0, NULL, NULL, 0, (LPMAPISESSION *) & pSession);



We will receive a pointer to the IMsgStore interface, we will need it later in order to determine the type of the intercepted message, in our case an incoming SMS.
....
IMAPITable * pIMapiStoresTable = NULL;
IMsgStore * pSMSStore = NULL;
....

hr = pSession-> GetMsgStoresTable (0, & pIMapiStoresTable);

while (1) {

SRowSet * pRowSet = NULL;

SizedSPropTagArray (2, tblColumns) = {2, {PR_DISPLAY_NAME, PR_ENTRYID}};
pIMapiStoresTable-> SetColumns ((LPSPropTagArray) & tblColumns, 0);
hr = pIMapiStoresTable-> QueryRows (1, 0, & pRowSet);

if (pRowSet-> cRows! = 1)
break;

// Compare with SMS, if it is the same, open the SMS storage
if (_tcscmp (TEXT ("SMS"), pRowSet-> aRow [0] .lpProps [0] .Value.lpszW) == 0)
{
ENTRYID * pEntry = (ENTRYID *) pRowSet-> aRow [0] .lpProps [1] .Value. bin.lpb;
ULONG ulStoreBytes = pRowSet-> aRow [0] .lpProps [1] .Value.bin.cb;
pSession-> OpenMsgStore (NULL, ulStoreBytes, pEntry, NULL, NULL, pSMSStore);
FreeProws (pRowSet);
break;
}

FreeProws (pRowSet);
};



Subscribe to the event of creating a new object, the flag fnevObjectCreated.
....
ULONG ulConnection = 101; // any number
CMAPIAdviseSink * pAdviseSink = NULL;

....
pAdviseSink = new CMAPIAdviseSink;
hr = pSession-> Advise (0, NULL, fnevObjectCreated, pAdviseSink, & ulConnection);
....


The implementation of the OnNotify method. In this place we will check what object was created and where, if in the Inbox folder, then we will somehow work with it. For example, delete, change the contents of the message, etc.

ULONG CMAPIAdviseSink :: OnNotify (ULONG cNotif, LPNOTIFICATION lpNotifications) {

HRESULT hr = S_OK;
SizedSPropTagArray (1, sptaEntryID) = {1, PR_CE_IPM_INBOX_ENTRYID};
ULONG cValues ​​= 0;
SPropValue * pspvEntryID = NULL;
IMessage * pMsg = NULL;

// Get the ID of the folder incoming SMS storage
hr = pSMSStore-> GetProps ((SPropTagArray *) & sptaEntryID,
MAPI_UNICODE, & cValues, & pspvEntryID);
if (FAILED (hr))
goto Exit;

ulong res;

/// C ID of the folder in which the intercepted object appeared
hr = pSession-> CompareEntryIDs (pspvEntryID-> Value.bin.cb, (LPENTRYID) pspvEntryID-> Value.bin.lpb,
lpNotifications-> info.obj.cbParentID, lpNotifications-> info.obj.lpParentID, 0, & res);
if (FAILED (hr))
{

goto Exit;
}
// If the ID is the same, we get a link to the interface IMessage, to work with the intercepted SMS
if (res == 1)
{

// Get the message from the entry ID
hr = pSession-> OpenEntry (lpNotifications-> info.obj.cbEntryID,
lpNotifications-> info.obj.lpEntryID, NULL, 0, NULL, (LPUNKNOWN *) & pMsg);
if (FAILED (hr))
{

goto Exit;
}

...
...
// In this place, we somehow process the intercepted message


}

Exit:
if (pspvEntryID)
{
MAPIFreeBuffer (pspvEntryID);
}

if (pMsg)
{
pMsg-> Release ();
}
return cNotif;
}


Delete all objects when we no longer need them and deinitialize MAPI

if (pIMapiStoresTable) pIMapiStoresTable-> Release ();
hr = pSession-> Unadvise (ulConnection);
pAdviseSink-> Release ();
pAdviseSink = NULL;
if (pSMSStore) pPop3Store-> Release ();
hr = pSession-> Logoff (0, 0, 0);
pSession-> Release ();
pSession = NULL;
MAPIUninitialize ();



Well, almost everything. I want to note that the described method intercepts both SMS messages and Email. By slightly correcting the code, it is possible to process both those and others, and not just the incoming ones.

Post has been editedconstv - 07.08.08, 10:14
YouROK85
Message#40
24.09.08, 16:13
Guru
*********
[offline]

Group: Developers
Messages 2787
Check in: 06.04.07
Meizu Pro 6 Plus 64GB

Reputation:-  517  +

The class for working with sockets pulled off the anti-chat;)
Attached fileSocket.rar(2.47 KB)


Attached file redone for PDA

examples below for BB, you need to redo

Sample client program:
Socket sock;
sock.connect ("mail.ru", 80);
sock << "GET http://mail.ru/ HTTP / 1.0 \ r \ n \ r \ n";

char buf [1024];
sock.set_buffer_size (sizeof (buf));
sock >> buf;
MessageBox (0, buf, "mail.ru", 0);
sock.close ();


Example of the server program (with error checking):
Socket serv;
if (serv.bind (8080) == - 1)
Return MessageBox (0, serv.getlasterror (), "Unable to bind socket", MB_ICONHAND);
if (serv.listen () == - 1)
Return MessageBox (0, serv.getlasterror (), "Unable to bind socket", MB_ICONHAND);
Socket * remote = serv.accept ();
if (! remote)
Return MessageBox (0, serv.getlasterror (), "Unable to accept connection", MB_ICONHAND);
char buf [1024];
remote-> set_buffer_size (sizeof (buf));
(* remote) >> buf;
(* remote) << "HTTP / 1.0 200 OK \ r \ nContent-Type: text / html \ r \ n \ r \ n

Socket class demo application Hello, World!";
remote-> close ();
serv.close ();
delete remote;

MessageBox (0, buf, "Remote", 0);



An example of inheritance is the Socks class for working with SOCKS proxies:
class Socks: public Socket
{
public:
int connect (char * proxy_host, int proxy_port, char * dest_host, int dest_port);
};

// Connect to SOCKS
int Socks :: connect (char * proxy_host, int proxy_port, char * dest_host, int dest_port)
{
set_terminate_flag (0);
if (Socket :: connect (proxy_host, proxy_port) == - 1)
return -1;

unsigned char packet [1024];
int bytes = 0;

memcpy (packet, "\ x05 \ x01 \ x00", 3);
send (packet, 3);
recv (packet, sizeof (packet));
bytes = get_last_length ();

if (* (WORD *) packet! = 0x0005)
{
close ();
return -1;
}

DWORD ip = nslookup_raw (dest_host);
if (! ip)
{
close ();
return -1;
}

packet [0] = 5; // VERSION: 5
packet [1] = 1; // METHOD: CONNECT
packet [2] = 0; // RSV: 0
packet [3] = 1; // ADTYPE: IPv4
* (DWORD *) & (packet [4]) = ip;
* (WORD *) & (packet [8]) = htons (dest_port);

send (packet, 10);
recv (packet, sizeof (packet));
bytes = get_last_length ();

if (bytes! = 10 || packet [1])
{
close ();
return -1;
}

set_terminate_flag (1);

return 0;
}


--------------------
Torrserve
M3U8 Loader
Thanks to everyone who supported me.
anper
Message#41
23.10.08, 22:49
Local
*****
[offline]

Group: Developers
Messages 165
Check in: 09.02.07

Reputation:-  29  +

My contribution: Work with bit fields. Redefinition of some types. And etc.
//******************************************************************************
// Name: macros.h
// Developed by: ANPER ([email protected])
//******************************************************************************

//------------------------------------------------------------------------------
#ifndef macros_h
#define macros_h

//------------------------------------------------------------------------------
typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed long s32;
typedef unsigned long u32;
typedef signed long long s64;
typedef unsigned long long u64;
typedef float flt;
typedef double dbl;

typedef volatile signed char vs8;
typedef volatile unsigned char vu8;
typedef volatile signed short vs16;
typedef volatile unsigned short vu16;
typedef volatile signed long vs32;
typedef volatile unsigned long vu32;
typedef volatile signed long long vs64;
typedef volatile unsigned long long vu64;
typedef volatile float vflt;
typedef volatile double vdbl;

//------------------------------------------------------------------------------
#define b (xBit) (1 << (xBit))
#define nb (xBit) (~ (1 << (xBit)))

#define bs (xVar, xBit) ((xVar) | b (xBit))
#define br (xVar, xBit) ((xVar) & (~ b (xBit)))
#define bc (xVar, xBit) ((xVar) & b (xBit))
#define ba (xVar, xBit) ((xVar) & b (xBit))
#define bo (xVar, xBit) ((xVar) | b (xBit))
#define bn (xVar, xBit) ((xVar) ~ b (xBit))
#define bx (xVar, xBit) ((xVar) ^ b (xBit))

#define sb (xVar, xBit) ((xVar) | = b (xBit))
#define rb (xVar, xBit) ((xVar) & = ~ b (xBit))
#define cb (xVar, xBit) ((xVar) & b (xBit))
#define xb (xVar, xBit) ((xVar) ^ = b (xBit))

#define ms (xVar, xMsk) ((xVar) | (xMsk))
#define mr (xVar, xMsk) ((xVar) & (~ (xMsk)))
#define mc (xVar, xMsk) ((xVar) & (xMsk))
#define mx (xVar, xMsk) ((xVar) ^ (xMsk))

#define sm (xVar, xMsk) ((xVar) | = (xMsk))
#define rm (xVar, xMsk) ((xVar) & = ~ (xMsk))
#define cm (xVar, xMsk) ((xVar) & (xMsk))
#define xm (xVar, xMsk) ((xVar) ^ = (xMsk))

#define rsm (xVar, xbRst, xbSet, xMsk) \
(ms (mr ((xVar), (xbRst)), (xbSet)) & xMsk)

#define B8 (xBit) (TU8 (1) << (xBit))
#define SL8 (xVar, xCnt) (TU8 (xVar) << (xCnt))
#define SR8 (xVar, xCnt) (TU8 (xVar) >> (xCnt))
#define B16 (xBit) (TU16 (1) << (xBit))
#define SL16 (xVar, xCnt) (TU16 (xVar) << (xCnt))
#define SR16 (xVar, xCnt) (TU16 (xVar) >> (xCnt))
#define B32 (xBit) (TU32 (1) << (xBit))
#define SL32 (xVar, xCnt) (TU32 (xVar) << (xCnt))
#define SR32 (xVar, xCnt) (TU32 (xVar) >> (xCnt))

#define SL (xVar, xCnt) ((xVar) << (xCnt))
#define SR (xVar, xCnt) ((xVar) >> (xCnt))
#define SLM (xVar, xCnt, xMsk) (((xVar) & (xMsk)) << (xCnt))
#define SRM (xVar, xCnt, xMsk) (((xVar) & (xMsk)) >> (xCnt))
#define BR (xVar, xcBit) ((xVar) & (~ (b (xcBit) -1)))

#define NGH (xVar) ((xVar) & 0xF0)
#define NGL (xVar) ((xVar) & 0x0F)
#define NHTL (xVar) (NGL (SR ((xVar), 4)))
#define NLTH (xVar) (NGH (SL ((xVar), 4)))

#define GAU8S (xAdr, xShift) (((u8 *) (xAdr)) + (xShift))
#define GAS8S (xAdr, xShift) (((s8 *) (xAdr)) + (xShift))

#define GVU8S (xAdr, xShift) (* (GAU8S ((xAdr), (xShift))))
#define GVS8S (xAdr, xShift) (* (GAS8S ((xAdr), (xShift))))

#define TU8 (xVal) ((u8) (xVal))
#define TU16 (xVal) ((u16) (xVal))
#define TU32 (xVal) ((u32) (xVal))
#define TS8 (xVal) ((s8) (xVal))
#define TS16 (xVal) ((s16) (xVal))
#define TS32 (xVal) ((s32) (xVal))

#define BTU8 (x7, x6, x5, x4, x3, x2, x1, x0) \
((x7) << 7) | ((x6) << 6) | ((x5) << 5) | ((x4) << 4) | ((x3) << 3) | ((x2) < <2) | ((x1) << 1) | ((x0))

#define CreateBitFieldU8 (xU8, x7, x6, x5, x4, x3, x2, x1, x0) \
union uU8B {\
u8 U8; \
struct sU8B {x0: 1; x1: 1; x2: 1; x3: 1; x4: 1; x5: 1; x6: 1; x7: 1;} B; \
} xU8

#define AnyAbs (xVal) (((xVal) <0)? (- (xVal)) :( xVal))
#define AnyABS (xVal) AnyAbs (xVal)
#define GetSign (xVal) ((! (xVal))? 0: (((xVal) <0)? (- 1): 1))
#define GetFldOffset (xStruct, xField) \
(((u32) & (xStruct)) - ((u32) & (xStruct.xField)))
#define GetFldOffset_p (xStruct, xField) \
(((u32) (xStruct)) - ((u32) & (xStruct-> xField)))

//------------------------------------------------------------------------------
#define LoopU8 (xIndex, xMax) for (u8 xIndex = 0; xIndex #define LoopU16 (xIndex, xMax) for (u16 xIndex = 0; xIndex #define LoopU32 (xIndex, xMax) for (u32 xIndex = 0; xIndex #define EndLoop}

#ifndef NULL
#define NULL 0
#endif

//------------------------------------------------------------------------------
union uUniVal {
vu8 buf [4]; vu8 U8; vs8 s8; vu16 U16; vs16 s16; vu32 U32; vs32 s32; vflt flt;
};

union uTmpVal {
u8 Buf [4]; u8 U8; s8 s8; u16 U16; s16 s16; u32 U32; s32 s32; flt flt; };

//------------------------------------------------------------------------------
/*
Rules: (1st (2nd) letter)
s - structure
e - transfer
u - union
c - class
m - macro
d - constant
x - parameter, variable
z is a local variable
p - pointer
b - bit operations
t - type

Abbreviations: (letter combinations)
Tag - description of enumeration, structure, association, class
Sub - sub action (sub variable)
Msg, M - message
Cnt - counter
Indx - index
Sts - device status (state)
Tsk - task for the device
Cfg configuration
Val - value
Int - internal
Ext - external
Exd - advanced
Evt, E - event
Mtx, Mx - Mutex
CS - critical section, object protected
Rto - coefficient
Lim - limit
Rd - read
Wr - record
Rdy readiness
Flg - flag
Rg, R - register
Sel - choice
Adr - address
Vec - vector
Itrpt - interrupt
Count - the last number
Size, S - size
Ctrl - control
Set, s - set
Reset, r, Rst - reset
Chk, c - check
Clr - clear
Msre - measurement
Auto - automatic
Crct - correction
HW - hardware
SW - software
Prsre - pressure
Sensor, Snsr - sensor, converter
Temper, Tmpr - temperature
Grd - graduation
Calib, Clbr - calibration
Crtrn - criterion
Rsrvd - reserve
*/
//------------------------------------------------------------------------------
#endif


Post has been edited-QwertY- - 28.10.08, 00:55

4 pagesV  < 1 2 3 4 > » 


 mobile version    Now: 06.22.19, 11:18