Hi,
How could I call an dll function using the number instead of name?
You need to get a handle to the module (DLL) that contains the function that you want to call, this is either done via LoadLibrary or GetModuleHandle function calls. You can then call GetProcAddress to get a pointer to the function.
For example assume you want to call:
int testfunc(int param) ;
You can do:
typedef int(* funcptr)(int) ;
hModule = LoadLibrary("dll name") ;
funcptr = GetProcAddress(hModule, MAKELONG(<ordinal>, 0)) ;
ret = funcptr(<param>) ;
Obviously you need to add error handling there, but thats the general idea.
thanks so much
Related
Trying to understand RIL and how to pass all the handles and various parameters. In my code i try to initialize RIL and then use the RIL_GetEquipmentInfo function to try and get some results from it. However when i try my application out , i get something like each time i press the command button ....
406
408
40B
411
....
it seems to increment and i thought i was ment to get something like HIMALAYAS back ... Where am i wrong ???
*********************************************
bool CTerminalDlg::RIL_Initialize(DWORD dwIndex)
{
TCHAR szString[256];
CEdit* pEditShow = (CEdit*)GetDlgItem(IDC_EDIT3);
result = ::RIL_Initialize(1, OnResultCallback, OnNotifyCallback, dwNotificationClasses, g_dwParam, &g_hRil);
HRESULT test = RIL_GetEquipmentInfo(g_hRil);
::wsprintf(szString, L" %X", test);
pEditShow->SetWindowText(szString);
return g_hRil != NULL;
}
the result is returned asyncronously via the OnResultCallback function.
alright i get ya ......... so that means the answer i should get ( HTC ) will be passed to a parameter inside the OnResultCallback function ? How would i display it in a message box though ?
thanks for your help i'm struggling here.
1)http://forum.xda-developers.com/viewtopic.php?t=28835
2)there is bad idea to show message box from callback
i think this callback execute in internal RIL thread
get data that you needed from RILEQUIPMENTINFO struct and put to temp buffer
show data from temp buffer in your main thread
for example:
in main thread
1)reset Event
2)call Ril_GetEquipmentInfo
3)wait Event
4)show MessgeBox
in callback
1)store data from RILEQUIPMENTINFO to temp buffer
2)set Event
3)return
Ok lets say i want to use this RIL function ... where would i get the data back from ??? Any help ?? I tried the CALL BACK functions but it does not seem to return much just some hexa stuff
Code:
HRESULT RIL_ReadMsg(
HRIL hRil, // @parm handle to RIL instance returned by <f RIL_Initialize>
DWORD dwIndex // @parm index of the message to be read
);
Hello everyone, it's my first post here.
Please help me with a small problem:
I have a WM6 device (Glofiish X800) with a VoIP enabled (WM6VoIP.cab). Built-in VoIP dialer works perfectly with my sipnet.ru profile.
Now I'm trying to initiate a VoIP call from my application. I use RTC API for this (rtcdll.dll etc.). I've got headers from the RTC Client API v.1.3 SDK for desktop.
Here are the examples I follow: http://msdn.microsoft.com/en-us/library/ms775274(VS.85).aspx
Everything compiles and runs ok, the objects get created, I even receive RTC events through IRTCEventNotification.
But when I try to enable and register my profile (exactly the same to which I provisioned and it worked), I receive RTCRS_ERROR state with the status 0x800703EB (ERROR_CAN_NOT_COMPLETE).
Code:
ThrowIfFailed(::CoCreateInstance(CLSID_RTCClient, NULL, CLSCTX_INPROC_SERVER, IID_IRTCClient, OUT (LPVOID*)(&client_))) ;
ThrowIfFailed(client_->Initialize()) ;
ThrowIfFailed(client_->QueryInterface(IID_IRTCClientProvisioning, OUT (LPVOID*) &prov_)) ;
ThrowIfFailed(client_->put_EventFilter(RTCRF_REGISTER_ALL)) ;
{
CComPtr<IConnectionPointContainer> connPtCont ;
ThrowIfFailed(client_->QueryInterface(IID_IConnectionPointContainer, OUT (void**)&connPtCont)) ;
ThrowIfFailed(connPtCont->FindConnectionPoint(IID_IRTCEventNotification, OUT &connPt_)) ;
CComPtr<IUnknown> myUnknown ;
ThrowIfFailed(QueryInterface(IID_IUnknown, OUT (void**)&myUnknown)) ;
ThrowIfFailed(connPt_->Advise(myUnknown, OUT &handlerConnectionCookie_)) ;
}
static const PCTSTR KProfileXml =
L"<provision key='1232ab01' name='SIPNET'>"
L" <provider name='SIPNET' />"
L" <user account='sim123456' password='s1i2m3'"
L" uri='sip:[email protected]'"
L" allowedauth='digest'/>"
L" <sipsrv addr='sipnet.ru:5060' protocol='UDP' role='proxy'>"
L" <session party='first' type='pc2pc' />"
L" <session party='first' type='pc2ph' />"
L" </sipsrv>"
L" <sipsrv addr='sipnet.ru:5060' protocol='UDP' role='registrar'/>"
L"</provision>"
;
CComBSTR profileXmlBstr(KProfileXml) ;
ThrowIfFailed(prov_->CreateProfile(profileXmlBstr, OUT &profile_)) ;
ThrowIfFailed(prov_->EnableProfile(profile_, RTCRF_REGISTER_ALL)) ;
I tried to pass 0 to EnableProfile() (to avoid registration) and then make a call.
I call CreateSession() and then AddParticipant(), then I receive RTCSS_INPROGRESS with status 0 and then RTCSS_DISCONNECTED with status 0x800703EB (ERROR_CAN_NOT_COMPLETE).
Code:
ThrowIfFailed(client_->CreateSession(RTCST_PC_TO_PHONE, 0, profile_, RTCCS_FORCE_PROFILE, OUT &session_)) ;
CComBSTR other(L"sip:[email protected]") ;
CComPtr<IRTCParticipant> participant ;
ThrowIfFailed(session_->AddParticipant(other, 0, OUT &participant)) ;
Please, anyone, if you've tried this at home, tell me what am I doing wrong?
The device is in flight mode, connected via ActiveSync USB, internet is accessible.
Here is the event handling code:
Code:
HRESULT CRtcDialog::Event( RTC_EVENT RTCEvent, IDispatch *pEvent )
{
PRINTF1(_CRtcDialog, "RTCEvent = %d", RTCEvent) ;
if (RTCEvent == RTCE_REGISTRATION_STATE_CHANGE)
return HandleRegistrationStateChange(pEvent) ;
if (RTCEvent == RTCE_SESSION_STATE_CHANGE)
return HandleSessionStateChange(pEvent) ;
return S_OK ;
}
HRESULT CRtcDialog::HandleRegistrationStateChange(IDispatch *pIDispatch)
{
ThrowIfNull(pIDispatch) ;
CComPtr<IRTCRegistrationStateChangeEvent> regChangeEvent ;
ThrowIfFailed(pIDispatch->QueryInterface(IID_IRTCRegistrationStateChangeEvent, OUT (void**)®ChangeEvent)) ;
HRESULT hr ;
RTC_REGISTRATION_STATE regState ;
hr = regChangeEvent->get_State(OUT ®State) ;
CComBSTR statusText ;
hr = regChangeEvent->get_StatusText(OUT &statusText) ;
long statusCode = 0 ;
hr = regChangeEvent->get_StatusCode(OUT &statusCode) ;
PRINTF3(_CRtcDialog, "regState = %d (0x%08X: %s)", regState, statusCode, statusText) ;
return S_OK ;
}
Thanks in advance.
Hi
i begin in level of system of WM5.
I have make some software in language C for WM5/WM6.
I search help for recover system information (network GPRS or WIFI, enumerate Available Access Points ,signalStrength,...),
if you know api for that thank you
Sorry for my english i say it is little poor
Hi
I have find solution i used i post solution if you are interessted:
pQueryOid = (PNDISUIO_QUERY_OID) Buffer;
pQueryOid->Oid = OID_802_11_BSSID_LIST;
pQueryOid->ptcDeviceName = /* your AdapterName*/
//-------------------------------------------------------------------------------------------------------------------------------------------------------
//creates, opens, or truncates a file, COM port, device, service, or console. It returns a handle that you can use to access the object.
handleDevice = CreateFile(NDISUIO_DEVICE_NAME,
GENERIC_READ|GENERIC_WRITE, 0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE) INVALID_HANDLE_VALUE);
if (handleDevice == INVALID_HANDLE_VALUE)
return NULL;
//sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
if (DeviceIoControl(handleDevice,
IOCTL_NDISUIO_QUERY_OID_VALUE,
(LPVOID) pQueryOid,
8192,
(LPVOID) pQueryOid,
8192,
&bytesWritten,
NULL))
Can't get rid of this error:
android.database.sqlite.SQLiteException: near "s": syntax error: , while compiling:
Select correct from answers where correct = 'Between the airplane's climb angle and the horizon.'
Obviously, it's finding the single quote in ( airplane's ) and considering that the end of the statement.
I've tried:
correct.replaceAll(" ' ", " ''' "); //replace 1 with 3
correct.replaceAll(" ' ", " '' "); // replace 1 with 2
correct.replaceAll(" ' ", " "); // replace 1 with space
(NOTE: the spaces are NOT in the code, I just did that to make it readable)
I have no idea what's going on, IMO, it should work. Maybe I need to try:
String single = "'"; // single '
String double = "''" // double ''
correct.replaceAll(single, double); // ????
Everything I"ve read about sqlite3 is to replace one with two....
TIA,
Roots
\'
\ is the escape character for most languages
so airplane's would be airplane\'s
Also, are you binding your queries with the "question mark" bind?
I'll try the escape and post back later. There are 1,000 rows in the database and I"m pulling a random subset of that, so it's not that often I get one of those situations.
I'm not sure what you mean by "binding with ?" Isn't that what you use for bind variable unknown at runtime? I know my bind variables and just use it in my dbquery. Please enlighten me...always happy to learn something new
Sample code...answerOne would contain the single quote that's killing me
Code:
Cursor c;
c = myDataBase.rawQuery("Select correct from answers where correct = '" + answerOne + "'", null);
if(c.moveToFirst())
answer = "1";
c.close();
binding with question marks should take care of escaping for you.
Basically the question mark is a place holder for a variable in the query.
What you are doing is manually creating the query string. This is considered bad practice these days especially with regards to security. Mostly because it opens up the DB to a SQL injection attack.
So instead of using the rawQuery just use query and you can put a ? in and android will substitute the value for you, all properly escaped:
Code:
String tableName = "answers";
String selectArgs = "correct=[COLOR="Red"]?[/COLOR]";
// if answerOne is string dont need String.valueOf
String[] selectVals = { String.valueOf ( answerOne ) };
String[] columnsProjection= new String[] {"correct" };
Cursor c = db.query(tableName, columnsProjection, selectArgs,selectVals,null);
So in that code the OS will replace the ? in selectArgs with the values in selectVals
This may seem like more writing at first but once you get in the habit it will be easy, reliable and more secure. It also allows you to bind multiple variables to mutiple question marks. It just binds then in the order it gets them.
so something like this:
Code:
String answerOne= "one";
String selectArgs = "correct=? AND age=? AND smiling=?";
String[] selectVals = { answerOne, "21", "yes" };
Ok, I'll try it. There are about 50 different queries in this program...for some reason I just decided to do a rawQuery on this one. I'll change it to "db.query(table name, new String[] {}....yada, yada).
Because, it just crashed and I decided to come back here and check for a solution.
Thank you very much!!!
Roots
Glad to be of help, just remember to hit the thanks booton ya Rooster
Still getting the error
Example: column is in table as text. Say it's equal to:
The driver's last name
Error comes back as "syntax error near 's' when compiling select correct from answers where correct = 'The driver's last name'
That single quote in driver's is killing my SQL.