Go to Post You know what they call the graduate with the lowest GPA in med school? Doctor. You know what they call the fourth robot in the alliance that wins Einstein? Champion. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-01-2003, 18:30
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Tokenizer Whitepaper Help

Here's the code I typed into a Win32 Application (not console):
Code:
HANDLE myLib = LoadLibrary("tokenizer.dll");

CompileProc Compile;
VerifyProc  TestRecAlignment;
VersionProc Version;
TModuleRec	tModRec;

Compile =          (CompileProc)GetProcAddress(myLib, "Compile");
	Version =		   (VersionProc)GetProcAddress(myLib, "Version");
	TestRecAlignment = (VerifyProc)GetProcAddress(myLib, "TestRecAlignment");
And here's the errors I get:
Code:
C:\Program Files\Microsoft Visual Studio\MyProjects\RoboCode\RoboCode.cpp(14) : error C2664: 'GetProcAddress' : cannot convert parameter 1 from 'void *' to 'struct HINSTANCE__ *'
        Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\Program Files\Microsoft Visual Studio\MyProjects\RoboCode\RoboCode.cpp(15) : error C2664: 'GetProcAddress' : cannot convert parameter 1 from 'void *' to 'struct HINSTANCE__ *'
        Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\Program Files\Microsoft Visual Studio\MyProjects\RoboCode\RoboCode.cpp(16) : error C2664: 'GetProcAddress' : cannot convert parameter 1 from 'void *' to 'struct HINSTANCE__ *'
        Conversion from 'void*' to pointer to non-'void' requires an explicit cast
The code compiled perfect when I did it in a console program, and all I did was copy/paste it (the code is in the "WinMain" thing). I've tried to fix it, but no luck, and I've looked up the errors on MSDN, but it didn't help me at all. Can someone help me please? The tokenizer.dll is in the folder where it's supposed to be (it loads correctly). I'm using MSVC++ 6.0 incase that helps at all.
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
  #2   Spotlight this post!  
Unread 07-01-2003, 19:01
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Sorry, that's my fault. Instead of declaring myLib as type HANDLE, make it HINSTANCE. Sorry for the confusion.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #3   Spotlight this post!  
Unread 07-01-2003, 19:03
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Quote:
Originally posted by rbayer
Sorry, that's my fault. Instead of declaring myLib as type HANDLE, make it HINSTANCE. Sorry for the confusion.
Ok, thank you...It's alright, I knew it was probably that though, but 1 question...why did it when without doing that in a console program?
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
  #4   Spotlight this post!  
Unread 07-01-2003, 19:23
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
It's possible that your Console app was setup to use C, whereas your new one is set for C++. Someone correct me if I'm wrong (which I probably am), but I'm guessing that the C compiler will convert pointer data types without even asking. After all, a pointer is just a pointer until you try to dereference it...
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #5   Spotlight this post!  
Unread 07-01-2003, 19:26
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
I'm not sure (I don't work with pointers alot), but you might be right. I don't think pointers work to well in C though (which goes along with my first statement). Is all your programs in MFC?
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
  #6   Spotlight this post!  
Unread 07-01-2003, 19:55
Mongoose's Avatar
Mongoose Mongoose is offline
Registered User
#0948 (Newport Robotics Group (NRG 948))
 
Join Date: Oct 2002
Location: Bellevue, WA
Posts: 45
Mongoose is an unknown quantity at this point
Send a message via AIM to Mongoose
I, too, might be wrong, but I believe C is more lax with pointers than C++. I know C++ *requires* you to type cast void pointers. (Perhaps that's why C is a better language for writing exploits?)
I never knew HANDLE was #define'd or typedef'd as a void*, which certainly adds to the confusion.
  #7   Spotlight this post!  
Unread 07-01-2003, 20:43
rwaliany's Avatar
rwaliany rwaliany is offline
R
None #0691 (HartBurn)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2000
Location: http://www.hartrobot.com
Posts: 137
rwaliany will become famous soon enough
yeah

Microsoft tends to add BS additions to their windows gui to make it look hard and make themselves look original.

LPCSTR

isnt that like

const char*

I prefer const char*, I dont know about you.
__________________
R
  #8   Spotlight this post!  
Unread 07-01-2003, 20:52
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Re: yeah

Quote:
Originally posted by rwaliany
Microsoft tends to add BS additions to their windows gui to make it look hard and make themselves look original.

LPCSTR

isnt that like

const char*

I prefer const char*, I dont know about you.
Take out the const and you're right. LPCSTR is never meant to be used by itself; you are always supposed to use LPCTSTR, so that code will automatically work under either Unicode or Ansi.

Also, using typedef in cases like this adds another layer of abstraction, which is a "good thing" from a software engineering view. Because this is translated directly into char * at compile-time, it's also one of the few abstractions that doesn't detract from performance.

That said, I never touched the MS-specific ones, except when dealing with MFC/API functions, while writing either RoboGUI or RoboEmu. Both use char * and I wouldn't have it any other way.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #9   Spotlight this post!  
Unread 08-01-2003, 14:23
jeremy562 jeremy562 is offline
Engineer
#0562 (SPARK 562)
 
Join Date: Feb 2002
Location: Fitchburg, MA
Posts: 74
jeremy562 is an unknown quantity at this point
Send a message via AIM to jeremy562
rbayer is right... Microsoft uses a LOT of macros and typedefs to abstract the data types, which is a GOOD thing.

If you look at the declarations, they are usually in some sort of #ifdef condition, so that by simply adding or removing a symbol from the preprocessor, your program can use different data types without changing any code. This is very useful if you want to be able to build your project with Unicode support.
  #10   Spotlight this post!  
Unread 08-01-2003, 16:21
rwaliany's Avatar
rwaliany rwaliany is offline
R
None #0691 (HartBurn)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2000
Location: http://www.hartrobot.com
Posts: 137
rwaliany will become famous soon enough
Microsoft

Still, but why use LPCTSTR, instead of like mStr, well I guess they do that for MFC. I would still rather do my own unicode support. I haven't found any good documentation with the prototypes for windows GUI and the defines such as HANDLE HINSTANCE. I've been stuck reading their header files. I like Linux GTK better, its so much more common sense to me.

I suppose that is because it takes 5-7 lines to add a toolbar to a window in GTK and 25-30+ in MSVC++ (NON MFC).
__________________
R
  #11   Spotlight this post!  
Unread 08-01-2003, 16:25
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
you can do something like:
#define NewName LPSTR
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
  #12   Spotlight this post!  
Unread 09-01-2003, 13:24
Ryan Meador Ryan Meador is offline
Registered User
#0190
Team Role: Electrical
 
Join Date: Jan 2002
Rookie Year: 1999
Location: Worcester, NH
Posts: 68
Ryan Meador will become famous soon enough
You're absolutely right in that C doesn't have much in the way of type-safety. Most of the WinAPI weird data types are #define'd void*'s or various species of int's. I use some of them and not others... just whatever fits the bill.
__________________
-Ryan

"You're not a real programmer until you end all your sentences with semicolons;"
  #13   Spotlight this post!  
Unread 09-01-2003, 18:28
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
The only thing I've found you can't use #define on is the comment (I wish I could though), and stuff like void, but I've not tried all of them.
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Documentation / Whitepaper Ideas. Josh Hambright General Forum 2 18-05-2003 17:15
Tokenizer Confusion Raven_Writer Programming 2 05-01-2003 16:23
How to use the PBASIC tokenizer rbayer Programming 0 12-12-2002 12:56
PBASIC Tokenizer Neal Probert Programming 9 28-10-2002 19:12
Edit whitepaper rbayer CD Forum Support 5 03-10-2002 18:11


All times are GMT -5. The time now is 11:54.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi