Ausgabe direkt von einem AttachProcess [Gelöst]

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
kwai chang caine
Beiträge: 57
Registriert: 29.11.2007 14:30

Ausgabe direkt von einem AttachProcess [Gelöst]

Beitrag von kwai chang caine »

Hallo an alle

Ich möchte wissen, ob es möglich ist, zu testen, eine Voraussetzung für die Frage einer DLL, und wenn sie nicht gut zu verlassen, ohne die Upgrade-Funktion aufrufen.

Dies auch, um den Test zu jeder Funktion, ohne daß man jedes Mal

Code des DLL

Code: Alles auswählen

ProcedureDLL AttachProcess(Instance) 
 
 Buffer.s = Space(1024)
 Bufsize.l = 1024 
 GetComputerName_(@Buffer, @Bufsize) 
 NamePc.s = Buffer
 
 If NamePc <> "ComputerName"
  MessageRequester("Test", "The name of the PC is no good", 0)
 EndIf
 
EndProcedure

ProcedureDLL Message() 
 MessageRequester("Test", "Hello is good", 0)
EndProcedure
Code des Programms

Code: Alles auswählen

OpenLibrary(0, "PureBasic.dll")
CallFunction(0, "Message")
CloseLibrary(0)
Ich danke Ihnen
Guten Tag
Zuletzt geändert von kwai chang caine am 04.06.2008 11:35, insgesamt 3-mal geändert.
Trotz all meiner Bemühungen.
Ich werde nie sprechen Deutsch

Dann ist das "google", das ist für mich
Danke
Benutzeravatar
nicolaus
Moderator
Beiträge: 1175
Registriert: 11.09.2004 13:09
Kontaktdaten:

Beitrag von nicolaus »

Hello,

sorry but google have translate your text so crasy that i don´t understand what you want to know.
Benutzeravatar
kwai chang caine
Beiträge: 57
Registriert: 29.11.2007 14:30

Beitrag von kwai chang caine »

:lol:
And in deutch i walk in the complet dark :D

I have asked the question, in the two forums, because it's a very hard question, same SROD which is a very good programer was not the answer :shock:

Well, I called the master Freak and he gave me the answer to ASM
I post the link, if a friend of this forum is interested:

http://www.purebasic.fr/english/viewtop ... highlight=

Thanks a lot for your interest 8)
Trotz all meiner Bemühungen.
Ich werde nie sprechen Deutsch

Dann ist das "google", das ist für mich
Danke
Benutzeravatar
kwai chang caine
Beiträge: 57
Registriert: 29.11.2007 14:30

Beitrag von kwai chang caine »

I have a new problem, the code of FREAK works fine for exit a DLL, without execute the rest of DLL.
Directly of the AttachProcess function 8)
It's really useful, for test if a program have the autorisation to use the DLL :D

It works fine when the DLL called by a PB program, else when the DLL called with VB6, i have an error 48 "File no found : PureBasic.dll" :cry:

Somebody know why VB call don't works ? :roll:

What is the difference of the DLL management between PB and VB6 ?

Code: Alles auswählen

ProcedureDLL AttachProcess(Instance) 
 
 Global AppPath.s
 AppPath = Space(200)
 GetCurrentDirectory_(200, @AppPath)
 AppPath = Trim(AppPath)
 
 If Right(AppPath,1) <> "\" 
  AppPath + "\" 
 EndIf

 Global NomExecutable.s
 Application.s = Space(255) 
 GetModuleFileName_(0, @Application, 255) 
 NomExecutable = GetFilePart(Application) 
 Application = ""
 
 Global AutorisationAppli = #False
 ReadFile(1, AppPath + "Autorisation")
 
 Repeat
 
  Donnee$ = ReadString(1)
  NomAppliFichier.s = StringField(UCase(Trim(Donnee$)), 1, "=")
  
  If FindString(UCase(Trim(NomExecutable)), NomAppliFichier, 1) 
   AutorisationAppli = #True
   Break
  EndIf
      
 Until Eof(1) <> 0
 
 CloseFile(1)
 
 If AutorisationAppli = #False

  MessageRequester(NomDLL, Space(8) + "Le logiciel " + NomExecutable + " n'est pas autorisé à utiliser " + NomDll + "," + Chr(13) + "veuillez contacter le développeur pour obtenir une autorisation.")

  !ADD esp, 8     ; remove Instance variable and return address from stack 
  !MOV eax, 0     ; set returnvalue to 0 
  !RET 12         ; return from DllEntryPoint 

 Else 

  ProcedureReturn ; return normally 

 EndIf 
 
EndProcedure
Trotz all meiner Bemühungen.
Ich werde nie sprechen Deutsch

Dann ist das "google", das ist für mich
Danke
Benutzeravatar
edel
Beiträge: 3667
Registriert: 28.07.2005 12:39
Computerausstattung: GameBoy
Kontaktdaten:

Beitrag von edel »

"File no found : PureBasic.dll"
dll in apppath ?
Benutzeravatar
kwai chang caine
Beiträge: 57
Registriert: 29.11.2007 14:30

Beitrag von kwai chang caine »

Yes, and i declare her like this :

Code: Alles auswählen

Private Declare Function Kcc Lib "PureBasic.dll" (ByVal Session As String) As Long
If i remove the code of FREAK, the DLL works fine in VB and in pb
Trotz all meiner Bemühungen.
Ich werde nie sprechen Deutsch

Dann ist das "google", das ist für mich
Danke
freak
PureBasic Team
Beiträge: 766
Registriert: 29.08.2004 00:20
Wohnort: Stuttgart

Beitrag von freak »

Then "File not found" is probably a generic error that VB displays when the dll cannot be loaded.
This is what you want, isn't it ? If you prevent the dll from loading, VB has to display some kind of error.
Benutzeravatar
kwai chang caine
Beiträge: 57
Registriert: 29.11.2007 14:30

Beitrag von kwai chang caine »

Hello FREAK, thanks to help me 8)

It's a normal comportement of VB for you !!!
But it's a more big mule that me, because the DLL is here, she just no be loaded.
This mule said "no DLL", if he said "The DLL can not be loaded" that is a good error message, but he said "no DLL". what a mule....

Perhaps, i must manage this error in VB ???

This VB, more i programing PB, more i hate him :evil:
Trotz all meiner Bemühungen.
Ich werde nie sprechen Deutsch

Dann ist das "google", das ist für mich
Danke
Benutzeravatar
kwai chang caine
Beiträge: 57
Registriert: 29.11.2007 14:30

Beitrag von kwai chang caine »

I read the VB doc, and see :
VB can not manage error DLL :twisted:
I search again
Trotz all meiner Bemühungen.
Ich werde nie sprechen Deutsch

Dann ist das "google", das ist für mich
Danke
Benutzeravatar
kwai chang caine
Beiträge: 57
Registriert: 29.11.2007 14:30

Beitrag von kwai chang caine »

I have some news about VB and the library, thank RENFIELD a VB programer :D

He said me, to use the API "LoadLibrary" before call the function in the DLL
And that's right, it's works :mrgreen:

I give in this forum this information, if a crazy like me use a day this fonction :D

Thanks you very much at all 8)
Trotz all meiner Bemühungen.
Ich werde nie sprechen Deutsch

Dann ist das "google", das ist für mich
Danke
Antworten