Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters
Register

Reply
 
LinkBack Thread Tools
Old 06.06.2002, 19:05   #1
Младенец
 
Join Date: 09 2001
Location: Armenia, Yerevan
Posts: 5
Downloads: 0
Uploads: 0
Reputation: 0 | 0
problem with dll

est' znachit vot takaya programma:

[CODE]#include <stdio.h>
#include <windows.h>

int main(){

HINSTANCE urldll;
int (WINAPI* offline)();
( urldll=LoadLibrary(&quot;URL.DLL&quot )
Reply With Quote
Old 06.06.2002, 19:09   #2
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
Post


pochemu eto ya "unregistered" i vidna tol'ko polovina post-a ?
Reply With Quote
Old 06.06.2002, 19:10   #3
Младенец
 
Join Date: 09 2001
Location: Armenia, Yerevan
Posts: 5
Downloads: 0
Uploads: 0
Reputation: 0 | 0
eshe raz:

est' znachit vot takaya programma:

[CODE]#include <stdio.h>
#include <windows.h>

int main(){

HINSTANCE urldll;
int (WINAPI* offline)();
( urldll=LoadLibrary(&quot;URL.DLL&quot )
Reply With Quote
Old 06.06.2002, 19:11   #4
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
Post

opyat' ne poluchilos'..
Reply With Quote
Old 06.06.2002, 19:23   #5
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
Post

v obshem vot programma:

#include <stdio.h>
#include <windows.h>

int main(){

HINSTANCE urldll;
int (WINAPI* offline)();
( urldll=LoadLibrary("URL.DLL") ) || printf("cannot load library, error %u",GetLastError());
( offline=GetProcAddress(urldll,"InetIsOffline") ) || printf("cannot import func");

printf("%s",offline()?"offline":"online");

FreeLibrary(urldll);
//exit(0);
return 0;
}

esli raskommentirovat' stroku s exit-om to programma visnet(performed an illegal operation)
v chem problema ?

P.S. esli pomestit' tut v ubb tag CODE || proisxodit chto-to neponyatnoe
Reply With Quote
Old 06.06.2002, 19:46   #6
Студент
 
Join Date: 01 2002
Location: Yerevan, Armenia
Age: 37
Posts: 282
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

2 z0mbie

vrode v kode vse ok, no u menya k tebe voprosi:

1. ti poproboval vizvat' functiyu
InetIsOffline ? Kakay reaktsiya?

2. prover', chto vozvraschaet FreeLibrary?
mojet nol'?

3. zachem tebe nujno vizivat' exit(0)?

i poslednee,

4. v chem tsel' progi?

P.S. mojet bit' problema v samoi dll.

____________________
Volka nogi kormyat
__________________
Сколько времени и сил должен потратить мужчина,
Чтобы воспользоваться минутной слабостью женщины
Reply With Quote
Old 06.06.2002, 19:52   #7
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
Post

Quote:
Originally posted by Talex:
2 z0mbie

vrode v kode vse ok, no u menya k tebe voprosi:

1. ti poproboval vizvat' functiyu
InetIsOffline ? Kakay reaktsiya?

2. zachem teb nujen exit(0)?

3. prover', chto vozvraschet FreeLibrary?

i poslednee, v chem tsel'?

1. ya eyo i vыzыvayu(sm. vыshe) normal'no rabotaet
2. ne nuzhen, prosto xotel proverit' gde oshibka voznikaet :]
3.TRUE

cel' v tom chtob uznat' online ya ili offline

DLL iz komplekta windows..
Reply With Quote
Old 07.06.2002, 00:24   #8
Бакалавр
 
Join Date: 03 2002
Location: Detroit, MI, USA
Posts: 482
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Quote:
Originally posted by z0mbie:
v obshem vot programma:

#include <stdio.h>
#include <windows.h>

int main(){

HINSTANCE urldll;
int (WINAPI* offline)();
( urldll=LoadLibrary("URL.DLL") ) || printf("cannot load library, error %u",GetLastError());
( offline=GetProcAddress(urldll,"InetIsOffline") ) || printf("cannot import func");

printf("%s",offline()?"offline":"online");

FreeLibrary(urldll);
//exit(0);
return 0;
}

esli raskommentirovat' stroku s exit-om to programma visnet(performed an illegal operation)
v chem problema ?

P.S. esli pomestit' tut v ubb tag CODE || proisxodit chto-to neponyatnoe
Pomoemu, u tebya problema s nepravil'noj signaturoj funkcii. Soglasno MSDN - u funciya vyglyadit tak:

BOOL InetIsOffline(DWORD dwFlags);

T.e., skoree vsego, u tebya razbalansirovalsya stek, poetomu, oshibka vsplyvaet pozje.
Poprobyj pomenyat' signaturu v svoem sample, i peredat' ej dwFlags = 0.

Udachi,
Hovik
Reply With Quote
Old 07.06.2002, 02:16   #9
Академик
 
greka's Avatar
 
Join Date: 09 2001
Location: inside myself
Posts: 5,369
Downloads: 0
Uploads: 0
Reputation: 18 | 5
Post

попробуй воспользоваться "FreeLibraryAndExitThread" вместо
"FreeLibrary".

Возможно вопрос в наличии child-тредов у DLL-ки, которые освобождаются некорректно.

Проявляется же это скорее всего именно после завершения функции.

Разница же в том (IMHO), что "return()" обрабатывает ошибки тихо, являясь "надстроечной" над стандартной (библиотечная ) функцией выхода "exiт".
Reply With Quote
Old 07.06.2002, 03:55   #10
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
Post

Tumanyan ya tozhe dumal chto signatura nepravil'naya no pri obyavlenii BOOL InetIsOffline(DWORD dwFlags); poluchayu error:
Cannot convert 'int (__stdcall *)()' to 'int (__stdcall *)(unsigned long)' in function main()

Greco El: spasibo, poluchilos' :]
Reply With Quote
Old 07.06.2002, 04:12   #11
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: 01 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,387
Downloads: 4
Uploads: 0
Reputation: 146 | 4
Post

Quote:
Originally posted by z0mbie:
pri obyavlenii BOOL InetIsOffline(DWORD dwFlags); poluchayu error:
Cannot convert 'int (__stdcall *)()' to 'int (__stdcall *)(unsigned long)' in function main()
ну так надо явно приводить один указатель к другому
Reply With Quote
Old 07.06.2002, 04:22   #12
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
Post

da kstati ya tam naoborot napisal, visnet pri vыxode return-om

Aram H. chto tut k chemu privodit' ne ponyal ?
Reply With Quote
Old 07.06.2002, 05:46   #13
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: 01 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,387
Downloads: 4
Uploads: 0
Reputation: 146 | 4
Post

Quote:
Originally posted by z0mbie:
Aram H. chto tut k chemu privodit' ne ponyal ?
значение, возвращаемое функцией GetProcAddress, привести к нужному типу, и завершить присваивание:

Code:
int (WINAPI* offline)(DWORD);
offline = (int (WINAPI*)(DWORD)) GetProcAddress(urldll,&quot;InetIsOffline&quot;);
или, если так не сработает (хотя должно вроде), можно пойти через typedef:

Code:
typedef int (WINAPI*)(DWORD) OfflineFunc;
OfflineFunc offline = (OfflineFunc) GetProcAddress(urldll,&quot;InetIsOffline&quot;);
Reply With Quote
Old 07.06.2002, 13:59   #14
»
 
z0mbie's Avatar
 
Join Date: 01 2002
Posts: 777
Downloads: 1
Uploads: 0
Reputation: 0 | 0
Post

ok Aram pasiba :]
tol'ko ne
typedef int (WINAPI*)(DWORD) OfflineFunc;
a
typedef int (WINAPI* OfflineFunc)(DWORD);
Reply With Quote
Old 07.06.2002, 15:44   #15
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: 01 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,387
Downloads: 4
Uploads: 0
Reputation: 146 | 4
Post

Quote:
Originally posted by z0mbie:
ok Aram pasiba :]
tol'ko ne
typedef int (WINAPI*)(DWORD) OfflineFunc;
a
typedef int (WINAPI* OfflineFunc)(DWORD);
упс совершенно верно
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 00:48.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.